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');
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');
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 site iframe
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.