【发布时间】:2012-10-26 11:25:04
【问题描述】:
我对 phonegap 很陌生。我在xcode4.5 中安装了phonegap2.1.0。现在phonegap工作正常。但是我怎样才能调用 web 服务并获得 phonegap 的 json 响应呢?我的代码在下面,但它不起作用。有人可以帮帮我吗?
$(document).ready(function () {
$.ajax({
alert("alert");
url: "http://localhost:55022/WebSite1/sample.asmx/returnEmployees",
data: null,
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg, textStatus, jqXHR){
alert(textStatus);
//var theRealData = msg.d;
/*
$.each(theRealData.employees, function (index, item) {
// at this point, item is an array, since theRealData.employees is an array of arrays
var col1 = item[0];
var col2 = item[1];
alert(col1);
}); */
},error:function(jqXHR, textStatus, errorThrown){
console.log(textStatus +"------" +errorThrown + jqXHR );
// navigator.notification.alert('Server Error');
}
});
});
【问题讨论】:
-
不写成功:成功:只是成功:
-
尝试成功:function(msg, textStatus, jqXHR)... 就像 Mehmet 建议的那样。如果您仍然有问题,请查看您的控制台,您是否收到任何错误?
-
@F481 感谢您的回复。我的控制台没有收到任何错误。你有什么想法。
-
@Mehmet 这次也没有得到结果。
-
@Mehmet 感谢您的回复。我已经编辑了我的问题。请通过我的问题。然后告诉我答案。
标签: javascript json cordova cocos2d-iphone xcode4.5