开发者

When calling a asmx service via jQuery, how to pass arguments?

开发者 https://www.devze.com 2022-12-29 16:17 出处:网络
How can I pass my service endpoint parameters? (pagesize in this case) My .asmx service method looks like:

How can I pass my service endpoint parameters? (pagesize in this case)

My .asmx service method looks like:

 [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public List&l开发者_StackOverflow中文版t;Object> GetData(int pageSize)
    {

    }

When I call this via jQuery like:

$.ajax({
        type: "POST",
        url: "test.asmx/test123",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {

        },
        error: function(msg) {

        }
    });


You can pass it as json:

$.ajax({
    type: "POST",
    url: "test.asmx/test123",
    data: "{'pageSize':'14'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) {

    },
    error: function(msg) {

    }
});


You need to build a json object:

data: {pageSize: 1}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号