开发者

JSONP parseerrror

I'm making crossdomain call with code:

$.ajax({
    type: "GET",
    url: data.Url,
    mimeType: "application/javascript",
    dataType: "jsonp",
    jsonp: false,
    cache: true,
    jsonpCallback: "getData",
    success: function(data){
        callback(data.html); 
    },
    error:function (xhr, ajaxOptions, thrownError){
        alert('Error during d开发者_如何学Pythonownloading ebook component:'+ componentId + ' thrownError:' + thrownError);
    }  
});

Server response with:

HTTP/1.1 200 OK
x-amz-id-2: YIPtShlPtOmDcIvn3ldRVkONQJTDxFba7OFWnL44A5HVZFXL0+9gGTnO/uZ5muFi
x-amz-request-id: AF6CF3B66F843250
Date: Mon, 08 Aug 2011 11:32:52 GMT
Last-Modified: Mon, 08 Aug 2011 11:24:51 GMT
ETag: "ee72cfb6fea66192a34b4fa72796b260"
Accept-Ranges: bytes
Content-Type: application/octet-stream
Content-Length: 30
Server: AmazonS3

getData({{"html":"example"}})

And as you may guess, error handler is executed with thrownError: 'getData was not called' and xhr.statusText: 'parseerror'.

Any Ideas? I'm pretty sure that I run this code sucessfully at friday(I've compared code with repository, but no diffrence), so I'm guessing it is something with server response.


{{"html":"example"}} is not a valid JSON syntax that's why you are getting parse error.

Try this instead {html:"example"}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜