[英]Set AJAX dataType using Vanilla javascript?
我正在使用这样的一些AJAX:
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","http://example.com",false);
xmlhttp.send();
data = xmlhttp.responseXML;
xmlhttp.responseXML以XML返回,因此它是一个javascript对象。 但是,我想要原始字符串格式。 类似于设置dataType: "text"
jQuery的$.ajax()
dataType: "text"
使用responseText
代替responseXML
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","http://example.com",false);
xmlhttp.send();
data = xmlhttp.responseText;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.