繁体   English   中英

Phonegap jQuery Ajax调用Web服务

[英]Phonegap jQuery Ajax to invoke a webservice

我试图使用jQuery .ajax从phonegap android应用程序调用Web服务,但是即时响应为null。

$ .ajax({类型:“ GET”,数据:'{continent:“'+ $('#txtContinent')。val()+'”}',URL:“ http:// localhost:60931 / Service1。 asmx / GetCountries”,

        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {

        alert(response);

        },
        failure: function(msg) {

            $('#result').empty().append(msg);
        }
    });

谁能帮助我使用jQuery .ajax从phonegap应用程序调用Web服务

在为您的Web服务实现JSONP之前,它不起作用。 JSONP允许进行远程调用,因为默认情况下不允许跨站点XHR调用。

JSONP for ASP.Net Webservices的一个不错的实现:

http://bloggingabout.net/blogs/adelkhalil/archive/2009/08/14/cross-domain-jsonp-with-jquery-call-step-by-step-guide.aspx

url: "Service1.asmx/GetCountries"

在应用程序中可以访问此服务URL吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM