android - 如何从 Jquery Mobile(Android 平台) 调用 asp.net webservice

标签 android asp.net jquery-mobile

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

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?

最佳答案

进行这些更改:

1.取消注释 [System.Web.Script.Services.ScriptService] 作为 Web 方法的属性

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?

关于android - 如何从 Jquery Mobile(Android 平台) 调用 asp.net webservice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10256577/

相关文章:

android - RXJava 将一个值传递给 onComplete

java - 为基于套接字的 Android 应用程序创建非卡住 UI 的理想方式

android - android资源中的词典

javascript - ASP.Net Ajax - JavaScript : How to display with returned variable in HTML

c# - 是否可以将 ASP.NET 应用程序部署为桌面应用程序(带有服务器组件)

javascript - Jquerymobile - 展开/折叠全部按钮

java - 在Android Studio中设计xml菜单不显示对象(按钮、 TextView 等)

javascript - 使用 javascript 选择客户端 ListView 中的所有复选框

外部链接上的 jQuery Mobile 后退按钮导致奇怪的问题

javascript - 使用 jquery 创建动态 html 页面