xmlHttp.responseXMl 获取不到值,- ajax !!!
同仁们,ajax 中,用xmlhttp 获取值时,xmlHttp.responseText 能获取到值,但我用 xmlHttp.responseXMl 就获取不到了,很是郁闷,望各位能指教!
我在servlet 中是这样写的:
StringBuffer res = new StringBuffer("<models>");
for(int i=0;i<v2.size();i++)
{
String ssh = (String)v2.get(i);
res.append("<model>");
res.append(ssh);
res.append("</model>");
}
res.append("</models>");
out.write(res.toString());
out.flush();
out.close();
=======
然后在页面中调用:
var res = xmlHttp.responseXML.getElementsByTagName("model");
获取到的res.length = 0 !!!!
后来我测试了一下,xmlHttp.responseText 是能获取到内容的!
用 xmlHttp.responseXML 就获取不到能容了,所以 res.length = 0
这是为什么 (声明: xmlHttp.status 很正常,200 ) ....