Cross-domain scripts using jQuery.support.cors = true

I worked on various examples demonstrating cross-domain scripts, and came across a situation where I wanted to use jQuery.support.cors = true along with an Ajax call to retrieve data from a web service. I have an example of working webservice using jsonp , which I thought would just add jQuery.support.cors = true, change the dataType type to "json" and delete & $ callback =? from url. I see an answer coming back from webservice (Netflix) with the expected data, but when the ajax call returns, it serves as an error, not a success.

Initially, I thought that perhaps the web service does not have the appropriate headers, but I would be inclined to think that the received formatted response would correspond to the existing header. Maybe I am not formatting the success / error function correctly and the Ajax result is not like.

Here is a script where it tries to use jQuery.support.cors to no avail.

+3
source share
2 answers

From: curl -i "http://odata.netflix.com/v2/Catalog/Titles?$select=Name,Runtime,ReleaseYear&$filter=dark&$orderby=Name&$format=json"

Cache-Control: private
Content-Length: 3386076
Content-Type: application/atom+xml;charset=utf-8
Expires: Tue, 01 May 2012 14:37:06 GMT
Vary: *
Server: Microsoft-IIS/7.0
DataServiceVersion: 2.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 01 May 2012 14:36:37 GMT

There is no header associated with CORS. Netflix does not allow CORS requests.

+5
source

Of course, in this example, Netflix blocks everything that happens outside their own servers.

+1
source

All Articles