Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery $(document).ready()未对ajax加载的内容执行_Jquery - Fatal编程技术网

Jquery $(document).ready()未对ajax加载的内容执行

Jquery $(document).ready()未对ajax加载的内容执行,jquery,Jquery,在返回的部分页面中不执行document.ready的原因可能是什么? 它可以正常工作2次,但在第3次更新html后什么也没有发生: alert(html); alert($(PopUpItem)); $(PopUpItem).html(html); alert('in set popup html completed'); 我已执行所有警报,PopupItem和html具有正确的值。 我使用JQuery通过$.post执行服务器调用 另外,如果发生语法错误,我是否可以让错误处理程序捕获?在

在返回的部分页面中不执行document.ready的原因可能是什么? 它可以正常工作2次,但在第3次更新html后什么也没有发生:

alert(html);
alert($(PopUpItem));
$(PopUpItem).html(html);
alert('in set popup html completed'); 
我已执行所有警报,PopupItem和html具有正确的值。 我使用JQuery通过$.post执行服务器调用


另外,如果发生语法错误,我是否可以让错误处理程序捕获?

在返回的AJAX中,不需要$(document).ready()调用。DOM已加载。像这样简单的事情应该可以做到:

<script type="text/javascript">
// Do something here.
</script>

//在这里做点什么。

document.ready仅在最初加载页面时执行


为了有一个错误处理程序,您可以使用more$.ajax来执行ajax调用()。

要将事件绑定到任何异步生成的元素,您应该查看livequery:

您是说传递给
$(PopUpItem)的
html
字符串包含一个
块,其中包含一个
document.ready(函数(){…});
在它里面

如果是这样,
ready
事件处理程序没有启动的原因是脚本根本没有运行。请查看哪个具有相同的“第三次”行为

不要将
标记加载到标记中。它根本不是可靠的跨浏览器、jQuery或no jQuery