我是手機新手。我被困住了。在調用webservice時,我無法獲得結果。我使用Ajax和getJSON方法。將結果取爲未定義的,RealData變量未定義。我覺得我失去了一些東西。請幫助傢伙。
這裏是我的代碼....PhoneGap中的Webservice
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(味精)。 msg變量上是否有任何內容? – caiocpricci2 2013-04-25 11:51:25
它給msg中的[object Object]響應。 – newBie 2013-04-25 11:54:05