Android PhoneGap中的Web服务
我是phonegap的新手。我卡住了。在phone gap中调用webservice时无法获得结果。我使用了Ajax和getJSON方法。将结果获取为未定义,将RealData变量获取为未定义。我觉得我错过了什么。请帮助大家。Android PhoneGap中的Web服务,android,web-services,cordova,undefined,Android,Web Services,Cordova,Undefined,我是phonegap的新手。我卡住了。在phone gap中调用webservice时无法获得结果。我使用了Ajax和getJSON方法。将结果获取为未定义,将RealData变量获取为未定义。我觉得我错过了什么。请帮助大家。 这是我的密码 function onDeviceReady() { console.log("Device is Ready111111"); alert("alert Device ready"); /*var jqxhr = $
这是我的密码
function onDeviceReady() {
console.log("Device is Ready111111");
alert("alert Device ready");
/*var jqxhr = $
.getJSON(
'http://www.infoline.in/mobdata.aspx?
reqfor=area_list&city=ahmedabad',
function() {
console.log("Device is Ready111111....."+jqxhr);
alert('success');
}).error(function() {
alert('error');
});*/
$(document).ready(function () {
$.ajax({
url: "http://www.infoline.in/mobdata.aspx",
data: {
"reqfor": "area_list",
"city": "ahmedabad"
},
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg, textStatus, jqXHR) {
alert(textStatus);
var theRealData = msg.d;
alert(theRealData.length)
}
});
});
为了查看对象,必须将消息转换为字符串 试试这个:
console.log(JSON.stringify(msg));
使用:console.log(msg)。msg变量上有什么东西吗?它在msg中给出[object object]响应。谢谢,现在得到了字符串如何解析整个json?你能给我一些指导吗。