开发者

jquery fails while page loads with xmlhttprequest

开发者 https://www.devze.com 2022-12-13 03:12 出处:网络
how should i apply jquery to php page loaded with xmlhttprequest i have tried it but when php page loads with xmlhttprequest the jquery fails. so what should i do so that jquery may work after page lo

how should i apply jquery to php page loaded with xmlhttprequest i have tried it but when php page loads with xmlhttprequest the jquery fails. so what should i do so that jquery may work after page load开发者_如何学Going.


If you load a page with xhr, you only do just that: load the contents of that page. If there are scripts in the page being loaded, they will not be executed which is what you want here.

So really, the best advice I can give here is to rethink your architecture. Would it be possible for you to have the scripts loaded in the page that does the xhr loading, rather than the target page? A terrible idea would be to have to parse the xhr.responseText to find script blocks and eval them. A nasty solution, but one that is used rather widely for performance reasons, is to send an xhr for the javascript files separately, and eval() them.


Use should use jQuery live method instead of bind if you have elements which are added later in your page through Ajax.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号