您的位置:首页 > Web前端 > Node.js

JQuery 错误提示:HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy

2013-11-12 17:27 633 查看
用JQuery的AJAX返回一些script脚本和html代码并运行这些代码,在测试的时候,发现在IE下正常,在火狐下并没有数据出现,通过调试,发现提示'Nodecannot be inserted at the specified point in thehierarchy'错误,百思不得其解,谷歌和百度均没有有效的解决办法。



通过查看JQuery的API。最终发现了问题所在。

下面是代码片段一,这段代码在IE下可以正常运行,但是在火狐下却提示脚本错误:

function getReservationData(d, f,url){
jQuery.ajax({
type: "post",
url: url,
data: {
searchdata: d,
flashcontainer: f,
a: Math.random()
},
error: function (){
return false;
},
success: function (data){
$("#" +f).html(data);
}
});
}


这段代码是通过URL返回一个javascript脚本段,并执行这个脚本。最终在IE下测试正常,但是在火狐和谷歌浏览器下发现无法执行脚本。但是在JQuery的API中看到有一个属性dataType,通过说明,明白需要指定dataType属性为html即可解决这个问题。

最终测试正确代码如下:

function getReservationData(d, f,url){
jQuery.ajax({
type: "post",
url: url,
data: {
searchdata: d,
flashcontainer: f,
a: Math.random()
},
dataType: 'html',
error: function (){
return false;
},
success: function (data){
$("#" +f).html(data);
}
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  浏览器 脚本 火狐