OL needs to support CORS and the HTTP 1.1 OPTIONS request method

Bug #617090 reported by raj
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Library
New
Medium
Anand Chitipothu

Bug Description

This particularly effects users who are trying to use jquery to access the OL API.

If you try to retrieve JSONP data using jquery's $.ajax(), $.getJSON() or related methods, jquery first makes a preflight request, as described in the CORS spec (http://www.w3.org/TR/cors/).

So a request for $.getJSON('http://openlibrary.org/books/OL1M.json?callback=foo') will first makes an OPTIONS request to that url, which will return a HTTP 405 error, which will cause the script to fail.

Workaround for jquery users:
If you use $.ajax() instead of $.getJSON() and set the dataType parameter to 'script', jquery will not make the OPTIONS request and just use the script src method to pull the data instead:

$.ajax({url: 'http://openlibrary.org/books/OL1M.json?callback=foo, dataType: 'script'});

George (george-archive)
Changed in openlibrary:
assignee: nobody → Anand Chitipothu (anandology)
importance: Undecided → Medium
milestone: none → general-bucket
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.