user270158
user270158

Reputation: 441

jquery load external files with http in url parameter

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!

Upvotes: 1

Views: 570

Answers (3)

Dani Cricco
Dani Cricco

Reputation: 8979

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.

Upvotes: 0

PJP
PJP

Reputation: 766

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.

Upvotes: 3

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103135

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.

Upvotes: 6

Related Questions