jquery load external files with http in url parameter
i've tried jquery .load() fu开发者_如何学运维nction. It is ok when i load files from my server, but i don't know how to load another file from www.
This is my code:
jQuery("#blog").load("/index.html");
jQuery("#blog").load("http://crocoweb.sk/");
The first one is working, the second not. On documentations I can't find how to use http as url parameter here. Please help!
AJAX is subjected to the same origin policy as a security feature of the browser. So unfortunately the second option will not work by design.
Another option is to do the include on the server.
You can't load a page coming from another source (domain) via ajax, unless using methods like JSONP. You can check out the ajax jQuery documentation for more information on JSONP.
You can add a proxy between your application and the third party domain. This cross domain querying solution works because you're actually loading the content from your own domain.
精彩评论