Reputation: 2256
I am trying to load a separate html file into an already existing div on a site and i am getting the following error :
XMLHttpRequest cannot load MyFile Origin null is not allowed by Access-Control-Allow-Origin. filename.html:1
I am using the load function as follows :
$("#wrapper").load('filename.html');
Upvotes: 0
Views: 144
Reputation: 281875
You can't load content from another domain like that - the Same Origin Policy prevents it for security reasons. You need to do one of these things:
Access-Control-Allow-Origin
header on the target siteiframe
Upvotes: 2
Reputation: 36000
Only URLs from the same domain is allowed to be embedded inside a div. Try hosting a local webserver and try loading the file from there.
$("#wrapper").load('./filename.html');
Upvotes: 2