我对phonegap很陌生。我安装了phonegap2.1.0
in xcode4.5
。现在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');
}
});
});