ajax 请求回来的数据总是undefined怎么回事
回调函数这样写的:functionupdatePage(){if(request.readyState==4){if(request.status==200){varxm...
回调函数这样写的:
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {
var xmlDoc = request.responseXML;
var showElements = xmlDoc.getElementsByTagName("result");
for (var x=0; x<showElements.length; x++) {
var newsid = showElements[x].childNodes[0].value;
var newstitle = showElements[x].childNodes[1].value;
// Now do whatever you want with the show title and ratings
}
document.getElementById("search_result").innerHTML = newsid+"|"+newstitle+"<br>";
}
}
}
我要输入的XML模板是这样的:
<?xml version="1.0" encoding="gb2312"?>
<blogsearch>
<result>
<logid>Id编号</logid>
<logtitle><![CDATA[文本内容]]></logtitle>
</result>
</blogsearch>
我单独输入xml可以,但用.getElementsByTagName("result")就取不到值 展开
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {
var xmlDoc = request.responseXML;
var showElements = xmlDoc.getElementsByTagName("result");
for (var x=0; x<showElements.length; x++) {
var newsid = showElements[x].childNodes[0].value;
var newstitle = showElements[x].childNodes[1].value;
// Now do whatever you want with the show title and ratings
}
document.getElementById("search_result").innerHTML = newsid+"|"+newstitle+"<br>";
}
}
}
我要输入的XML模板是这样的:
<?xml version="1.0" encoding="gb2312"?>
<blogsearch>
<result>
<logid>Id编号</logid>
<logtitle><![CDATA[文本内容]]></logtitle>
</result>
</blogsearch>
我单独输入xml可以,但用.getElementsByTagName("result")就取不到值 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询