Nothing
Nothing

Reputation: 2642

Origin null is not allowed by Access-Control-Allow-Origin not working with jsonp

I searched, many answers here. But I tried it all, It still does not work for me. I want to to get json data from web service (cross domain).

var url1 = 'http://localhost:33219/iSes/Pro/RfsPro.svc/GetPro/';
$.getJSON(url1,function(json){
    alert('testing');
});

I got error from Chrome console Origin null is not allowed by Access-Control-Allow-Origin.

These are what I tried to do, by searching the answers here :

  1. Put /?callback=? to url :

    var url1 = 'http://localhost:33219/iSes/Pro/RfsPro.svc/GetPro/?callback=?';
    
  2. I found chrome.exe --allow-file-access-from-files but if we use this, do the clients that browse our website have to do it too?

  3. This answer, 3rd option related to CORS, using PHP to configure the header, How could I do this with ajax or jquery? Because my project is using backbone.jsnot PHP.

Upvotes: 0

Views: 1639

Answers (1)

Idipaolo
Idipaolo

Reputation: 788

While the source url and the destination url don't match you will always have this error!

You can't do an ajax request from "file:///E:/Project/WebSite/SourceWebsite/test.html", to "http://yourdomain:33219/iSes/Pro/RfsPro.svc/GetPro/", because it's a violation of the Same Origin Policy.

http://en.wikipedia.org/wiki/Same-origin_policy

You can do an ajax request to the server if and only if the protocol, url and port are the same.

If you want to access to : "http://yourdomain:33219/iSes/Pro/RfsPro.svc/GetPro/"

You must be at "http://yourdomain:33219/something"

I hope I made myself clear.

Upvotes: 1

Related Questions