即使返回json也可以不支持jsonp吗? [英] Can jsonp be not supported even if json is being returned ?
问题描述
Guys i am trying to hit this webservice which returns me a json response {"message":"ok","client_transaction_id":"2","transaction_token":"e52126c2b0570335ab33ce3a233c18aea90c7987","status":"1","img":"http://www.zipdial.com/zip2auth/images/access/e52126c2b0570335ab33ce3a233c18aea90c7987"} Now obviously i need it in a variable and need to make a cross domain call using jsonp but i get an "Uncaught SyntaxError: Unexpected token : " in chrome and "invalid label" in firefox . Following are the calls that i have tried a) <pre lang="Javascript"> $.ajax({ type: ''GET'', url: Url, contentType: "application/json", crossDomain: true, data: {"customerToken": "31f65a57b1d6106c067bc00a51f9128f4db95d1d", "clientTransactionId": "2", "callerid": "9968280904", duration: "180", "countryCode": "91", "z2vToken": "884acdd6f4293432e922d1d4b4566a3c9f1203c1"}, dataType: ''jsonp'', success: function() { console.log(''Success!''); }, error: function() { console.log(''Uh Oh!''); }, jsonp: ''jsonp'' });
我得到了哦作为答案
b)
jQuery.getJSON(urlFromApi + " ,功能(数据){
警报(数据);
});
上面使用yahoo的开放式api进行的调用使它像一个魅力一样工作,但是当与网络服务一起使用时,我实际上需要使用的调用给了我与上面相同的错误.
因此,webservice(我没有使用过的第三方api)可能不支持jsonp吗?
输入:"GET",
网址:网址,
contentType:"application/json",
crossDomain:是的,
数据:{"customerToken":"31f65a57b1d6106c067bc00a51f9128f4db95d1d","clientTransactionId":"2","callerid":"9968280904",持续时间:"180","countryCode":"91","z2vToken":"884acdd6f4293432d2c
dataType:``jsonp'',
成功:function(){console.log(''Success!''); },
错误:function(){console.log(``哦哦!''); },
jsonp:``jsonp''
});
我得到了哦作为答案
b)
jQuery.getJSON(urlFromApi + " ,函数(数据){
警报(数据);
});
上面与yahoo的开放api一起使用的调用使它像一个魅力一样工作,但是当与Web服务一起使用时,我实际上需要使用的调用给了我与上面相同的错误.
因此,webservice(我没有使用过的第三方api)可能不支持jsonp吗?
Guys i am trying to hit this webservice which returns me a json response {"message":"ok","client_transaction_id":"2","transaction_token":"e52126c2b0570335ab33ce3a233c18aea90c7987","status":"1","img":"http://www.zipdial.com/zip2auth/images/access/e52126c2b0570335ab33ce3a233c18aea90c7987"} Now obviously i need it in a variable and need to make a cross domain call using jsonp but i get an "Uncaught SyntaxError: Unexpected token : " in chrome and "invalid label" in firefox . Following are the calls that i have tried a) <pre lang="Javascript"> $.ajax({ type: ''GET'', url: Url, contentType: "application/json", crossDomain: true, data: {"customerToken": "31f65a57b1d6106c067bc00a51f9128f4db95d1d", "clientTransactionId": "2", "callerid": "9968280904", duration: "180", "countryCode": "91", "z2vToken": "884acdd6f4293432e922d1d4b4566a3c9f1203c1"}, dataType: ''jsonp'', success: function() { console.log(''Success!''); }, error: function() { console.log(''Uh Oh!''); }, jsonp: ''jsonp'' });
i get uh oh as the answer
b)
jQuery.getJSON(urlFromApi+"&callback=?",function(data) {
alert(data);
});
The call used above with yahoo''s open apis makes it work like a charm but when used with the webservice i actually need to use gives me the same error as above.
So is possible that webservice(third party api on which i have no use) dos not support jsonp ?
.ajax({ type: ''GET'', url: Url, contentType: "application/json", crossDomain: true, data: {"customerToken": "31f65a57b1d6106c067bc00a51f9128f4db95d1d", "clientTransactionId": "2", "callerid": "9968280904", duration: "180", "countryCode": "91", "z2vToken": "884acdd6f4293432e922d1d4b4566a3c9f1203c1"}, dataType: ''jsonp'', success: function() { console.log(''Success!''); }, error: function() { console.log(''Uh Oh!''); }, jsonp: ''jsonp'' });
i get uh oh as the answer
b)jQuery.getJSON(urlFromApi+"&callback=?",function(data) { alert(data); });
The call used above with yahoo''s open apis makes it work like a charm but when used with the webservice i actually need to use gives me the same error as above.
So is possible that webservice(third party api on which i have no use) dos not support jsonp ?
这篇关于即使返回json也可以不支持jsonp吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!