0
我对phonegap非常陌生。我在xcode4.5
中安装了phonegap2.1.0
。现在phonegap工作正常。但是,我怎样才能调用Web服务,并得到一个JSON响应phonegap?我的代码在下面,但它不起作用。有谁能够帮助我?如何使用phonegap调用webservice并获取json响应iphone
$(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');
}
});
});
不写成功:成功:只是成功: – Mehmet
尝试成功:函数(味精,textStatus,jqXHR)...像穆罕默德建议。 如果你仍然有问题看看你的控制台,你有任何错误? – F481
@Mehmet谢谢。 – sathis