开发者

jQuery .ajax() with jsonp not invoking success callback function

I have a facebook iframe application that makes a cross domain request to my server and requests data in JSONP format. This is my client side code:

jQuery.ajax({
                url: '***',
                type: 'post',
                data: {
                    method: 'set_user_prizes'
                },
                dataType: 'jsonp',
                jsonp: false,
                jsonpCallbackString: 'callback123',
                success: function(data, textStatus, jqXHR){
    开发者_JAVA技巧                console.log('success_function');
                    console.log(data);
                }
});

The problem is my success callback method isn't being invoked and I'm not sure why. Using Firebug I can see my server's response:

callback123({"success":true,"associated_prizes":[{"prizes_id":"6"},{"prizes_id":"1"}]})


Remove the word String from the callback key as is illustrated in the following transformation. The value needs to remain a string.

Change:

jsonpCallbackString: 'callback123',

to

jsonpCallback: 'callback123',


The correct answer is

jsonpCallback: 'callback123'
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜