jQuery mobile开发iPad上的应用软件,怎么调用C#写的Web Service?Web Service(或WCF)是在一个网站上的,我的app是在IOS的本地跑的,使用jQuery mobile做开发,想要接收和调用Web Service上的数据和接口.求助!!!!!jquerymobilewebc#ipad

解决方案 »

  1.   

    iso的浏览器应该支持ajax吧,配置你的webservice可以get/post请求,用ajax请求webservice获取返回的数据就行了不支持ajax可以使用script加载webservice,webservice输出符合js语法的数据就行了
      

  2.   

    $('#pDownload').click(function() {
    //alert("sa");
    var frmData = $("#form1").serialize();
            $.ajax({
    type: 'post',
            url: 'http://localhost:1727/WCFservice.svc/InsertRow',
            contentType: 'text/json',
            data: '{"id":'+23+',"title":"'+'32d'+'","content":"'+'2323ss'+'"}',
            success: function(msg) {
            var a = eval('('+msg+')');
            if(String(a.d).length>0){alert(a.d);}
            else{alert("服务器超时");}
            }
            })
    });
    ajax不能跨域名访问吧?我这样写,FireBug会警告错误:"NetworkError: 404 Not Found - http://localhost:1727/WCFservice.svc/InsertRow"
    C#的Web Service代码:
    namespace jqueryWCF
    {
        [ServiceContract(Namespace = "")]
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class WCFservice
        {
            [OperationContract]
            [WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
            public string InsertRow(int id,string title,string content)
            {
                return string.Format("您输入的标题是:{0}\n\n您输入的内容是:{1}\n\n此文章的id是:{2}",title,content,id.ToString());
            }
        }
    }
      

  3.   

    端口不一致再firefox下也算跨域。。统一端口号可以用jsonp跨域取数据
      

  4.   

    jQuery mobile运行在手机上的怎么调用WCF web service啊?
    我打开网址:
    http://192.168.0.104/dcmsservice/DataService.svc/GetData3?agentBm=31,devName=2F%E6%B8%A9%E6%B9%BF%E5%BA%A6%E7%9B%91%E6%B5%8B,id=1101001
    得到的是"服务 不允许此方法",但是我有这个接口啊.
      

  5.   

    能不能让WCF直接通过网址返回一串json或xml的数据?
      

  6.   

    你没配置wcf服务可以get访问吧。。楼主自己找下如何配置,没搞过wcf~~
      

  7.   


    知道不允许get问题了,参考这个:Ext4 JSONStore加载webservice返回的json数据,最近发现的,