I want to load in <div class="test"> some content from another URL ex: http://someurl.com/default.aspx.
I tried this code:
$(".test").load( 'http://someurl.com/default.aspx');
But it doesn’t work.
With local file it works, but not with http://…
Can somebody help me?
Thanks
It looks like you have bumped into the same origin policy. You have to use a relative path for the
load()method, otherwise most browsers will simply return an emptyresponseText.As one possible workaround, you could set up a very simple reverse proxy (using mod_proxy if you are on Apache). This would allow you to use relative paths in your AJAX request, while the HTTP server would be acting as a proxy to any “remote” location.
The fundamental configuration directive to set up a reverse proxy in mod_proxy is the ProxyPass. You would typically use it as follows:
In this case, the browser would be requesting
/ajax/default.aspxbut in fact the server would serve this by acting as a proxy tohttp://someurl.com/default.aspx.If you are using IIS, you may want to use the Managed Fusion URL Rewriter and Reverse Proxy to set up a reverse proxy.