I've been working on various samples showing off cross-domain scripting and ran into a case where I wanted to use jQuery.support.cors = true along with an Ajax call to retrieve data from a webservice. I have an example of the webservice working using jsonp that I thought would be simple to add jQuery.support.cors = true, change the dataType to "json", and remove the &$callback=? from the url. I can see the response ing back from the webservice (Netflix) with the expected data, but when the ajax call returns it executes the error functions as opposed to success.
I originally thought that maybe the webservice did not have the proper cors headers, but I would tend to think a formatted response received would equate to the header existing. Perhaps I'm not formatting the success/error function properly and the Ajax result does not like that.
Here is the fiddle where it is attempting to use jQuery.support.cors to no avail.
I've been working on various samples showing off cross-domain scripting and ran into a case where I wanted to use jQuery.support.cors = true along with an Ajax call to retrieve data from a webservice. I have an example of the webservice working using jsonp that I thought would be simple to add jQuery.support.cors = true, change the dataType to "json", and remove the &$callback=? from the url. I can see the response ing back from the webservice (Netflix) with the expected data, but when the ajax call returns it executes the error functions as opposed to success.
I originally thought that maybe the webservice did not have the proper cors headers, but I would tend to think a formatted response received would equate to the header existing. Perhaps I'm not formatting the success/error function properly and the Ajax result does not like that.
Here is the fiddle where it is attempting to use jQuery.support.cors to no avail.
Share Improve this question asked May 1, 2012 at 14:30 ShelbyZShelbyZ 1,5041 gold badge14 silver badges32 bronze badges 1- "I would tend to think a formatted response received would equate to the header existing" — It doesn't. – Quentin Commented May 1, 2012 at 14:35
2 Answers
Reset to default 5From: curl -i "http://odataflix./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 CORS related header. Netflix do not permit CORS requests.
Surely in this example, Netflix would be blocking anything originating outside their own servers.