2011-09-02 2 views
1

다음과 같이 AJAX를 사용하고 있습니다.바닐라 자바 ​​스크립트를 사용하여 AJAX 데이터 유형을 설정 하시겠습니까?

xmlhttp=new XMLHttpRequest(); 
    xmlhttp.open("GET","http://example.com",false); 
    xmlhttp.send(); 
    data = xmlhttp.responseXML; 

xmlhttp.responseXML은 XML로 반환되므로 자바 스크립트 객체입니다. 그러나, 원시 문자열 형식으로하고 싶습니다. jQuery의 dataType: "text"에서 dataType: "text"을 설정하는 것과 비슷한 점 $.ajax()

답변

3

사용 responseTextdataType: "text"을 설정하는 대신 responseXML

xmlhttp=new XMLHttpRequest(); 
xmlhttp.open("GET","http://example.com",false); 
xmlhttp.send(); 
data = xmlhttp.responseText; 
에 가깝다 뭔가
관련 문제