如果你看到的jQuery的有关方法的源代码,他们做
...
self.html(
selector ?
// Create a dummy div to hold the results
jQuery("<div>")
// inject the contents of the document in, removing the scripts
// to avoid any 'Permission Denied' errors in IE
.append(res.responseText.replace(rscript, ""))
// Locate the specified elements
.find(selector) :
// If not, just inject the full result
res.responseText
);
...
所以,如果提供一个选择(如你的情况),他们删除脚本,以避免在IE权限被拒绝的错误。
你需要使用jQuery .get()
方法
像
$("#nav a").click(function() {
$.get(this.hash.substring(1), function(response){
var dummy = $('<div>').append(response).find('#content_inload');
$("#inload_container").html(dummy);
});
});
另外请注意,我已经使用了#inload_container
作为目标元素为你插入#content_inload
到自身模仿这个代码,实际上是复制的。
更新
您的评论后,那么我想,工作
$("#nav a").click(function() {
$.get(this.hash.substring(1), function(response){
$("#inload_container").empty().append(response).find('>*:not(#content_inload)').remove();
});
});
下面似乎有可能是当你创建在内存中的jQuery对象的脚本元素的问题吗? (不能确定的原因)
在你的具体情况,上述解决方案将工作,但它不是很优雅,从它意味着它添加到DOM从ajax调用返回的一切,然后过滤出来的东西,我们不希望..
它可能会更好干脆就只是改变你的实际视频页面(一个从阿贾克斯加载),做一个正常的没有任何过滤了..
在样品http://www.divethegap.com/update/community/videos/(点击测试视频)。 – 2010-11-07 14:49:13
加载页面中的内容是什么? – 2010-11-07 14:50:25