3

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 coming 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.

1
  • "I would tend to think a formatted response received would equate to the header existing" — It doesn't. Commented May 1, 2012 at 14:35

2 Answers 2

5

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 CORS related header. Netflix do not permit CORS requests.

Sign up to request clarification or add additional context in comments.

2 Comments

I guess II'm not certain why I can still see the resulting data payload if they don't support cors. Shouldn't the query be blocked in total?
@ShelbyZ — No. Just not visible to JavaScript.
1

Surely in this example, Netflix would be blocking anything originating outside their own servers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.