jquerypagemethods

Passing jquery search results to a page method


I have am using a sortable jQuery list. I would like to send the results of that list to a webmethod for processing.

So my javascript is something like:

function ProcessSortableList() {
    var arr = {};

    arr[0] = "item1";
    arr[1] = "item2";
    PageMethods.TestMe(arr);
}

I then have a webmethod on the server side:

    [WebMethod]
    public static String TestMe(String[] items)
    {
        ... Do stuff here ...
    }

The web method doesn't get called. If I change the webmethod so it takes a single parameter ...

TestMe(string item)

... and then I call it with a single value

PageMethods.Test('item1')

everything works fine.

What gives?


Solution

  • Change

    var arr = {} 
    

    to

    var arr = new Array()