none
spring.net ajax调用webservice RRS feed

  • 问题

  • 这是别人写好的代码,bll层的IWebservice代码

    namespace BLL.IWebService
    {
        public interface IBPartsWebService : IBaseService
        {
         
        
     
            System.Data.DataSet DQueryDataSet(string orderField, int pageSize, int currentPage, int orderType, string[][] fields, out int records, SessionModel sessionModel = null);
        }
    }

    我现在需要用ajax调用webservice,代码怎么写?

    $.ajax({
                 contentType:"application/json",
                    url: "/BPartsWebService.asmx/DQueryDataSet",
                    //data: "{gradeid:'" + gradeid + "' }",
                    //data: "{}",
                    //dataType: "xml",
                     
                     data: {
                   
                    },



    please verify my account

    2016年4月24日 2:05

答案

全部回复

  • 具体实现参考:http://www.cnblogs.com/micromouse/archive/2010/07/06/1772515.html

    和:http://www.cnblogs.com/finehappy/archive/2009/02/01/1382123.html

    http://www.cnblogs.com/frozenzhang/p/ajax.html

    $.ajax({
                    url: "/CommonService.asmx/SayHello",
                    type: "Post",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: "{name:'Varchar32'}",
                    success: function (data) {
                        alert(data.d);
                    },
                    error: function (data) {
                        //200的响应也有可能被认定为error,responseText中没有Message部分
                        alert($.parseJSON(data.responseText).Message);
                    },
                    complete: function (data) {
                        ;//after success or error
                    }
    
    // 对应服务定义:
    [WebMethod]
      public string SayHello(string name)
          {
              return "Hello " + name;
           }


    If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer. My sample

    2016年4月24日 3:15
  • 它的那个方法是这样的:

    System.Data.DataSet DQueryDataSet(string orderField, int pageSize, int currentPage, int orderType, string[][] fields, out int records, SessionModel sessionModel = null);

    我的怎么调用那


    please verify my account

    2016年4月24日 3:26
  • Hi,

    Learning hard的答案已经很明确了啊,把对应的参数转成json字符串放到data那一栏去:

    $.ajax({
                    url: "/BPartsWebService.asmx/DQueryDataSet",//url
                    type: "Post",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: "{orderField:'123',pageSize:2,currentPage:5,...}",//把参数填入这个部分
                    success: function (data) {
                        alert(data.d);
                    },
                    error: function (data) {
                        //200的响应也有可能被认定为error,responseText中没有Message部分
                        alert($.parseJSON(data.responseText).Message);
                    },
                    complete: function (data) {
                        ;//after success or error
                    }

    Regards,

    Moonlight


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    2016年4月26日 8:36