Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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<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) {

        }
    });
like image 829
Blankman Avatar asked Dec 22 '22 03:12

Blankman


1 Answers

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) {

    }
});
like image 162
Nick Avatar answered Mar 04 '23 20:03

Nick