JQuery JSONP cross domain call not doing anything

。_饼干妹妹 提交于 2019-12-05 14:22:22

You're having issues because that's not how the response actually looks :)

When you specify jsonp or callback=? it gets replaced, it's actually doing: ?callback=functioName, which turns your response from something like this:

{"test_param":12345}

To this:

functionName({"test_param":12345});

That's needed for JSONP to work. Check out the updated URL to see what I mean: http://twitter.com/users/usejquery.json?callback=functionName

OK after a good nights sleep I've solved the problem. I didn't realise these was a difference between the two response formats. When I queried twitter just using my browser the response didn't include the function name which confused me.

//JSON
{"name":"stackoverflow","id":5}
//JSONP
func({"name":"stackoverflow","id":5});
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!