Phonegap + Webservice

时间:2012-10-26 07:43:32

标签: android asp.net jquery cordova mobile

我有一个带有对webservice(ASP.NET)的ajax调用的index.html,当我在bigrock服务器上部署它时,它运行正常(我有一个域)。

$.ajax({
        type: "POST",
        url: "myurl/mywebservice.asmx",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert("success");
        },
        error: function (msg,status) {
           $('#demo').html("status is "+status+" . Msg is "+msg.d.responseText);
           //attribute for responsetext might be wrong here but in my application it is correct as i am using different system ryt now.
        }
    });

但是,当我使用phonegap的在线拉链从html,css,js,web.config为我的Android应用程序制作apk时,很少有类并将其安装在我的设备上......没有任何问题。它显示我没有responseText的ajax错误。

我缺少什么?

2 个答案:

答案 0 :(得分:1)

当您压缩资产以提交到PhoneGap Build时,您需要添加config.xml file并指定类似于

的访问策略
<access origin="https://your.domain.com" />

这将指示PhoneGap允许与您的服务器通信。

答案 1 :(得分:0)

当您的应用使用PhoneGap部署到设备时,您的“主页”位置将成为本地设备上的文件系统。

这意味着任何ajax调用都是跨域调用,需要进一步配置才能正确设置。

请参阅this question for potential answer

相关问题