Click here to Skip to main content
15,795,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello i am trying to call a webmethod from a jquery but its giving me 500 Internal Error
Below is my javascript code and Webmethod
function submit() {
    var idsInOrder = $("#sortable").sortable("toArray");
    var string_arr = idsInOrder.toString();
    console.log("STRN-" + string_arr);
    var url = "pgArrange.aspx/SaveListOrder";
        type: "POST",
        url: url,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: "{'catalogname':'" + string_arr + "'}",
        success: function (data) {

    public static string SaveListOrder(string ids)
        string id = "";
        foreach(string s in ids.Split(','))
            if (s != "")
                id = id + s + ",";
            //int id = ids[i];
            //int ordinal = i;
        return id;

Use Fiddler to examine the traffic between your browser and server as it often shows you the real error messages. Off the top of my head you are passing a param called catalogname but your method is expecting a param called "ids". The param names have to match.
Share this answer
The issue is with the parameter name mismatch. WebMethod parameter name is ids, but you are sending catalogname.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900