使用Android模拟器运行时,AJAX调用不会在Cordova应用程序中通过JSONP [英] AJAX call not not going through on JSONP in Cordova app when run with Android emulator
问题描述
我在HTML5中创建了一个Cordova应用程序。我试图在jQuery中进行AJAX调用并使用restAPI进行调用。它与Ripples工作正常,但不能与Android模拟器4.4一起工作。
我使用的代码如下:
I have created a Cordova app in HTML5. I am trying to make an AJAX call in jQuery and calling with restAPI. It's working fine with Ripples but not working with android emulator 4.4.
I am using the code below:
var wcfServiceUrl = "http://dev3/DCLocalGateWay/LocalGateWay/RestGateWay.svc/GetMessage";
$.ajax({
url: wcfServiceUrl,
type: "GET",
contentType: "application/javascript; charset=utf-8",
crossDomain: true,
dataType: "jsonp",
async: false,
error: function (error) {
alert("Menu failed!");
alert(error);
},
success: function (response) {
alert(response.GetMessageResult);
}
});
资源无法加载是我得到的错误我什么时候这一切都在模拟器或bluestack中。当我使用涟漪时,它的工作正常。我们的服务返回JSON。我已经尝试过使用$ .getjson,XHR(XML HTTP Request)。所有方法都给出了相同的错误。
任何指导都将不胜感激。
VM
Resource could not be loaded is the error I am getting when I call this in emulator or bluestack. While I am using ripples, its working fine. Our service returns JSON. I have already tried using $.getjson, XHR (XML HTTP Request). All methods give same error.
Any guidance would be greatly appreciated.
VM
推荐答案
.ajax({
url:wcfServiceUrl,
type: GET,
contentType: application / javascript; charset = utf-8,
crossDomain: true ,
dataType: jsonp,
async: false ,
错误: function (错误){
alert( 菜单失败! );
alert(错误);
},
成功: function (响应){
警报(response.GetMessageResult);
}
});
.ajax({ url: wcfServiceUrl, type: "GET", contentType: "application/javascript; charset=utf-8", crossDomain: true, dataType: "jsonp", async: false, error: function (error) { alert("Menu failed!"); alert(error); }, success: function (response) { alert(response.GetMessageResult); } });
资源无法加载是我得到的错误当我在模拟器或bluestack中调用它时。当我使用涟漪时,它的工作正常。我们的服务返回JSON。我已经尝试使用
Resource could not be loaded is the error I am getting when I call this in emulator or bluestack. While I am using ripples, its working fine. Our service returns JSON. I have already tried using
.getjson,XHR(XML HTTP Request)。所有方法都给出了相同的错误。
任何指导都将不胜感激。
VM
.getjson, XHR (XML HTTP Request). All methods give same error.
Any guidance would be greatly appreciated.
VM
这篇关于使用Android模拟器运行时,AJAX调用不会在Cordova应用程序中通过JSONP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!