geo geo - 1 month ago 8
Ajax Question

Jquery jsonp reqeust callback function not firing

I'm try to making a cross-domain request by jQuery ajax. However the callback function can not be firing.

Below is js code.

$.ajax({
type: "get",
url: "http://xx.cc/yy/zz.qq?ppp=xx&callback=?",
dataType: "jsonp",
success: function (result) {
$("#frequentlyBoughtContainer").html(result);
InitPageData();
}
});


And the server side response like this:

Request URL:http://qaps.cc/qaps/BehaviorData!GetPageSlots.qs?ProductId=24875&PersonalizationMode=C&callback=jQuery171016283606179058552_1381370760591&_=1381370766821

Status Code:200 OK

Request Headers:

Accept:*/*

Accept-Encoding:gzip,deflate,sdch

Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4

Cache-Control:no-cache

Connection:keep-alive

Pragma:no-cache


Query String Parameters:

ProductId:24875

PersonalizationMode:C

callback:jQuery171016283606179058552_1381370760591
_:1381370766821

Response Headers:

Cache-Control:private

Content-Length:10144

Content-Type:text/javascript; charset=utf-8


And this is response content:


jQuery1710162836061790585521381370760591(" ...... \u003cli\u003e\r\n \u003cp class=\"showImg\"\u003e\r\n .....")


Have i make a mistake?

Answer

Please try to see if there's an error in the console. It could be a problem in the returned data.

$.ajax({
    type: "get",
    url: "http://xx.cc/yy/zz.qq?ppp=xx&callback=?",
    dataType: "jsonp",
    success: function (result) {                
        console.log(result);            
    }
});
Comments