jQuery .load remote content into div, keep scope for links etc
if I load a file contents into a div using:
$("testDiv").load('http://outserver/Siteb/search');
I get the search page in the div. The page in question has a search form. I want 开发者_如何学Pythonthe resulting page to be bound within the same div, rather than take over as normal.
Is there any way to do this?
Use IFRAME to do this:
<iframe src="http://outserver/Siteb/search" width="200" height="200"></iframe>
Or Create whole View logic by jQuery
1) $("#testDiv").load('http://outserver/Siteb/search');
2) $("form").submit() //handle form submit and submit it via AJAX call
3) get results through AJAX
4) display results in div, without need to refresh page
First of all you can't use load to do this because, as the documentation state,
Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol
If you want to do that on the same domain, you should definitly load it into an iframe as Marek suggested
精彩评论