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.
精彩评论