1

i've tried jquery .load() function. 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!

1
  • 2
    You cannot do that, thanks to security measures in web browsers. Google for "same origin policy." Commented Aug 30, 2010 at 12:52

3 Answers 3

6

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.