0

I have the following javascript code for an autoselect dropdownlist with multiselect checkbox:

function f() {

    var data;
    $("#csrch").attr('value', '');
    $.ajax
    ({
        //calling aspx web method
        url: 'drpCtrl.aspx/CustomerFilter',
        type: 'POST',
        //since webmethod does not have parameter given data as empty
        data: '',
        datatype: 'json',
        contentType: 'application/json',
        mimeType: 'application/json',
        error: function (jqxhr, status, error) {

            alert(error)
        }
    });
}

Which is calling this web method from the code behind page

[WebMethod]
public string CustomerFilter()
{
    string result = "";
    //retrieving customer list from database where it returns as json format
    result = Convert.ToString(objSLA.ExecuteScalar       (CommandType.StoredProcedure, "Usp_Get_Customer_Test"));
    //returning string format
    return result;
}

Webmethod CustomerFilter() is not calling and I am getting the Internal Server Error..Please help what is wrong in above said coding result:

{
   "uin":{
      "customer":[
         {
            "i":"1",
            "n":"Ahold Financial Services"
         },
         {
            "i":"2",
            "n":"ALM"
         },
         {
            "i":"3",
            "n":"Associated Global Systems, Inc."
         }
      ]
   }
}

1 Answer 1

0

try adding the static at you Codebehind Method:

[WebMethod]
    public static string CustomerFilter()
    {
        string result = "";
        //retrieving customer list from database where it returns as json format
        result = Convert.ToString(objSLA.ExecuteScalar       (CommandType.StoredProcedure, "Usp_Get_Customer_Test"));
        //returning string format
        return result;
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.