【问题标题】:How to call asp.net webservice from Jquery Mobile(Android Platform)如何从 Jquery Mobile(Android 平台)调用 asp.net 网络服务
【发布时间】:2012-11-14 08:22:36
【问题描述】:

我是一名 .net 开发人员,愿意学习移动网络技术。目前我正在Android平台上工作。我发现 Jquery 是适合我的框架,因为我来自网络背景。到目前为止,我能够在 android 上创建一个简单的 Web 应用程序,但是我无法从 Jquery 向我的 .net Web 服务进行 AJAX 调用。我想为我的 android web 应用创建一个测试环境。

1. I have ASP.NET web service running on my local computer 

    namespace JqueryMobile
    {
        [System.Web.Script.Services.ScriptService]
        public class WebService1 : System.Web.Services.WebService
        {

            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }
        }
    }
my webservice URL is : http://localhost:26415/WebService1.asmx

2. My android index.html 

     $(function(){
                $.ajax({url:"localhost:26415/WebService1.asmx/HelloWorld",
                success:function(result){
                           alert(result);
                           }});
     });
    This technique fails in local environment so, how do i test it?

【问题讨论】:

  • 尝试让 web 服务在某些机器上运行,然后分配该 ip 而不是 localhost。

标签: android asp.net jquery-mobile


【解决方案1】:

进行这些更改:

1.uncomment [System.Web.Script.Services.ScriptService] 作为 Web Method 的属性

2.还将您的网址更改为喜欢http://localhost:1096/MySite/WebService.asmx/HelloWorld?callback

3.尝试使用IP地址代替loaclhost http://IPADDRESS:1096/MySite/WebService.asmx/HelloWorld?callback

看到这个帖子:What is the best way to call a .net webservice using jquery?

【讨论】:

    猜你喜欢
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多