0

我创建了一个 wcf 服务和一个 phonegap 应用程序来使用 wcf 服务。当我使用 IIS 部署 Mywcf 服务时,它不会进行调试,但它是使用“Visual Studio 开发服务器”运行的。当我运行 phonegap 应用程序成功功能时,数据显示“未定义”,然后显示错误消息。我的phonegap代码如下:

$(document).ready(function () {
$.getJSON("http://localhost:20999/MobileService.svc/GetProductCategories", {
beforeSend: function (xhr) {
},complete: function () {
$.mobile.hidePageLoadingMsg();},
contentType: "application/json; charset=utf-8",
dataType: 'json',
type: 'GET',
success: function (data) {
    alert("success");
    alert("Exito " + JSON.stringify(data));  },
error: function () {
alert('Something awful happened');
}});});

什么问题???

4

1 回答 1

0

For your success function try.

alert("Exito " + JSON.stringify(data[0]));  },

You may have to post code of your WCF service and set up the service to run through IIS instead of the port. It looks like the service is trying to return an object that you're not identifying with the data value.

Usually you have to do something like

alert("Exito " + JSON.stringify(data.[Object Name]));  },
于 2013-04-26T03:08:10.063 回答