2013-03-23 103 views
0

我已经创建了wcf服务和phonegap应用程序来使用wcf服务。 当我使用IIS部署Mywcf服务时,Mywcf服务不会进行调试,但它使用“Visual Studio Development Server”运行。 当我运行我的phonegap应用程序成功功能运行,但数据显示“未定义”,然后显示错误信息。 我PhoneGap的代码是根据:使用phonegap消费wcf服务

$(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'); 
}});}); 

是什么问题???

回答

0

为您的成功功能尝试。

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

您可能需要发布WCF服务的代码,并将服务设置为通过IIS而不是端口运行。它看起来像服务试图返回一个对象,你不能识别数据值。

通常你必须做一些像

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