How To Pass a MultiDimensional Array from Javascript to server using PageMethods in ASP.Net

I have some <li> Items in my HTML Page like this

<li id="A1" class="ui-state-default">Item 2</li>
  <li id="A2" class="ui-state-default">Item 3</li>
  <li id="A3" class="ui-state-default">Item 4</li>
  <li id="A4" class="ui-state-default">Item 5</li>

I called It using Javascript and Jquery like this to get the Id and Index of the <li> elements

function LiOrder() {
            var order = $('li').map(function (i) {
                return { id:, index: i };

            PageMethods.GetServerResponse(order, OnSuccess, OnFail);

        function OnSuccess(arg) {

WebMethod Written in Aspx.cs Page is this

    public static string GetServerResponse(string[,] LiOrder)

        return LiOrder[0,0];

But when I try to execute it I get Error like this in Google Chrome (Javascript Console)

POST http://localhost:2453/ERP29.1.13/Production/LifeCycleRegistration.aspx/GetServerResponse 500 (Internal Server Error) ScriptResource.axd:6979

What might be the reason for this error. I could pass a string to WebMethod like this. But when it comes to Array, its like this. Please Help me to resolve this



JSON.stringfy resolved my issue. I changed my code like this

var LiArr=JSON.stringify(order);
            PageMethods.GetServerResponse(LiArr, OnSuccess, OnFail);


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.