Shopify JSONP issue in ajaxAPI

Posted by Aaron U on Stack Overflow See other posts from Stack Overflow or by Aaron U
Published on 2012-12-18T14:08:18Z Indexed on 2012/12/18 17:03 UTC
Read the original article Hit count: 420

Filed under:
|
|
|

I'm getting some odd response back from shopify ajaxapi for jsonp.

If you cURL a Shopify ajax api location

http://storename.domain.com/cart.json?callback=handler

you will get a jsonp response. But something is breaking the same request in browsers.

It appears to be related to compression? Here are some responses from each browser when attempting to call the jsonp as documented.

  • Firefox: The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
  • Internet Explorer: Internet Explorer cannot display the webpage
  • Chrome/Safari/Webkit: Cannot decode raw data, or failed (chrome)

Attempted use via jquery:

$.getJSON('http://storename.domain.com/cart.json?callback=?', function(data) { ... });
// Results in a failed request, viewable network request panels of dev tools

Here is some output from cURL including response headers:

$ curl -i http://storename.domain.com/cart.json?callback=CALLBACK_FUNC

HTTP/1.1 200 OK
Server: nginx
Date: Tue, 18 Dec 2012 13:48:29 GMT
Content-Type: application/javascript; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 200 OK
ETag: cachable:864076445587123764313132415008994143575
Cache-Control: max-age=0, private, must-revalidate
X-Alternate-Cache-Key: cachable:11795444887523410552615529412743919200
X-Cache: hit, server
X-Request-Id: a0c33a55230fe42bce79b462f6fe450d
X-UA-Compatible: IE=Edge,chrome=1
Set-Cookie: _session_id=b6ace1d7b0dbedd37f7787d10e173131; path=/; HttpOnly
X-Runtime: 0.033811
P3P: CP="NOI DSP COR NID ADMa OPTa OUR NOR"

CALLBACK_FUNC({"token":null,"note":null,"attributes":{},"total_price":0,...})

Also related unanswered here: Shopify Ajax API JSONP supported?

Thanks

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about jsonp