XMLHttpRequest cannot load.?

I by chrome->Inspect element->console get this error:

XMLHttpRequest cannot load. Origin is not allowed by
Access-Control-Allow-Origin.

What is this resolved?

You cannot issue requests through the XMLHttpRequest to other domains or subdomains.
If you are issuing the request from www.foo.com you also need to target the request at www.foo.com and not leave out the www.

If you really need to hit another domain you can use JsonP where the browser utilizes the <script> tags ability to load scripts from a different domain. The loaded script then executes a callback function to give you the data. But for regular AJAX calls you cannot leave the source domain at all.

See the Wiki article on Same Origin Policy

one work around is using Korz which routes all cross origin requests through a third party and sets Access-Control-Allow-Origin header to ‘*’ so the request goes through.

I recommend you to read this:
http://www.fbloggs.com/2010/07/09/how-to-access-cross-domain-data-with-ajax-using-jsonp-jquery-and-php/

It is very wel explained… the whole point is that you need to return your JSON in a callback-function way


The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   Node npm package throw use strict: command not found after publish and install globaly

Similar Posts