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:
我有一个facebook iframe应用程序,它向我的服务器发出跨域请求,并以JSONP格式请求数据。这是我的客户端代码:
jQuery.ajax({
url: '***',
type: 'post',
data: {
method: 'set_user_prizes'
},
dataType: 'jsonp',
jsonp: false,
jsonpCallbackString: 'callback123',
success: function(data, textStatus, jqXHR){
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:
问题是我的成功回调方法没有被调用,我也不知道为什么。使用Firebug,我可以看到我的服务器的响应:
callback123({"success":true,"associated_prizes":[{"prizes_id":"6"},{"prizes_id":"1"}]})
2 个解决方案
#1
6
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',
#2
4
The correct answer is
正确的答案是
jsonpCallback: 'callback123'
#1
6
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',
#2
4
The correct answer is
正确的答案是
jsonpCallback: 'callback123'