【发布时间】:2014-02-13 01:34:36
【问题描述】:
我的任务是更新一个最初编写为只能在 IE 中运行的网站,并使其能够跨浏览器运行。
我现在收到一条错误消息:
对象不支持属性或方法'selectNodes'
在从 IE 特定的 Ajax 调用更新为应该跨浏览器工作的 jquery ajax 调用之后的 ajax 调用的输出:
这是调用的原始函数:
function XmlHttpRequestBlocking(url, http_type, return_xml, content) {
var http_request = new ActiveXObject('Microsoft.XMLHTTP');
if(http_request == undefined)
return undefined;
try
{
http_request.open(http_type, url, false);
http_request.send(content);
if(http_request.status == 403)
{
top.location = "Login.aspx";
return undefined;
}
else if (http_request.status == 200)
{
if (return_xml) {
return http_request.responseXML;
}
else {
return http_request.responseText;
}
}
else
return undefined;
}
catch(e)
{
return undefined;
}
}
然后替换为:
function XmlHttpRequestBlocking(url, http_type, return_xml, content) {
var x;
jQuery.ajax({
url: url,
type: 'GET',
async: false,
success: function (result) {
x = result;
}
});
return x;
}
现在对函数的以下调用并尝试解析输出会在 IE 中产生错误“对象不支持属性或方法'selectNodes'”
var capture_station_list = XmlHttpRequestBlocking(g_get_status_url, "GET", true, "");
var stations = capture_station_list.selectNodes("//channel");
我在想返回的xml格式一定不一样吧?尝试 console.log 的 jquery 版本的输出显示 [object Document] 返回。
【问题讨论】:
标签: jquery ajax xml internet-explorer