[英]Error doing a jsonp ajax call
Using this code 使用此代码
$.getJSON("http://mydomain.com/getcustomers?callback=?",function(data) {
....
}).error(function(err){
....
})
I'm getting 我越来越
jQuery16103492487950357067_1336742910384 was not called
jQuery16103492487950950357067_1336742910384未调用
I searched on google and some people points to a incompatibility with jquery validate, I'm not using that plugin on this page. 我在Google上搜索,有人指出与jquery validate不兼容,我不在此页面上使用该插件。 I also tried to replace the $.getJSON call by a $.ajax call in order to have more control but the result is the same.
我还尝试用$ .ajax调用替换$ .getJSON调用,以便获得更多控制权,但结果是相同的。
Anyone knows what is causing this? 有人知道是什么原因造成的吗?
Does the service where GetCustomers method lives really support JSON-P? GetCustomers方法所在的服务是否真的支持JSON-P? You should be able to see the responses in Fiddler.
您应该能够在Fiddler中看到响应。
You can install Fiddler. 您可以安装Fiddler。 Download it from www.fiddler2.com.
从www.fiddler2.com下载。 In case of JSON-P, the JSON-part is wrapped by a function call.
对于JSON-P,JSON部分由函数调用包装。
Your response will look like this: 您的回复将如下所示:
Basically, it is a hack in order to get around the same-origin policy, but since parties such as Google are using it heavily as well, you can "safely" use it. 基本上,这是为了绕过相同来源的政策而设计的,但是由于Google等各方也大量使用它,因此您可以“安全地”使用它。 What is returned by the server is actually a javascript function.
服务器返回的实际上是一个javascript函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.