javascript - XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin -


I am developing a page that draws pictures through jQuery's AJAX support from Flickr and Panoramas.

Flickr is working fine, but when I $ I try to get (url, callback) from Panoram, then I see an error in Chrome's console:

XMLHttpRequest can not load. Original tap is not allowed by access-control-permission-origin.

If I ask the URL directly from the browser, then it works fine, what is going on, and can I find around it? Am I writing my query incorrectly or is it something that interferes with what I'm trying to do to Panoramium?

Google did not turn on any useful mail.

Edit

Here is some sample code that shows a problem:

  $ (). Ready (function () {var url = 'http: //www.panoramio.com/wapi/data/get_photos?v=1&key=dummykey&tag=test&offset=0&length=20&callback=processImages& Minx = -30 & amp; miny = 0 & amp; maxx = 0 & amp; Maxy = 150 '; $ .get (url, function (jsonp) {var process image = function (data) {warning (' OK ');}; eval (jsonp );});});  

You can.

Edit 2

Thanks to Darin for helping him with this. The above code is incorrect. Instead, use:

  $ (). Ready (work () {var url = 'http://www.panoramio.com/appi/data/get_photos?v=1 & amp; key = dummy & amp = tag = test and offset = 0 & length = 20 & amp; minx = -30 & amp; miny = 0 & amp; maxx = 0 & amp; maxy = 150 & amp; callback =? & # .get (url, function (data) {// 'data' Can be used here ...});}); For the record, as far as I can tell, you have two problems:  

  1. You can get your $ The "jsonp" type specifier was not going in Get , so it was using a normal XMLHttpRequest However, if your server has fixed it, then your browser to allow cross-domain XMLHttpRequest CORS (Cross-origin resource sharing) Access-Control-Permission-Origin header came in.

  2. I believe that you have mentioned that you are running it from the file: // URL. There are two ways for the CORS header to indicate that a cross-domain XHR is OK. One has to send the access-control-permission-origin: * (if you had access to Flickr through $ .make it , they would be doing it) while others However, file: // url generates a zero generator , to echo back to the content of the original header, which is the echo back Can not be authorized by.

To use Darin's suggestion, $. GetJSON was used in the first roundabout manner. Looking at the sub-code callback = in the URL, the magic from "Jason" to "JasonCP" has a little magic to change the request type.

Second, a CORS is not trying to request a URL from a file: // .

To clarify to others, here are the general troubleshooting instructions:

  1. If you are trying to use JSONP, make sure that the following There is one of the cases:
    • You can change the $. Are using and Jsonp .
    • Are you using $ .getJSON and in the URL callback =? are included.
  2. If you are trying to do cross-domain XMLHttpRequest through CORS ...
    1. Make sure that you http: / / . The scripts running through file: // have limited support for CORS.
    2. Make sure the browser (Opera and Internet Explorer is late for the party)

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -