Server side method not getting called

Posted by Rangel Fernandes on Stack Overflow See other posts from Stack Overflow or by Rangel Fernandes
Published on 2013-10-25T21:51:37Z Indexed on 2013/10/25 21:53 UTC
Read the original article Hit count: 122

Filed under:
|
|

From the below javascript code i am trying to call a serverside method, but serververside method is not getting called. I am using jquery, ajax

<script type="text/javascript" src="JquryLib.js"></script>
<script type="text/javascript" language="javascript">
    function fnPopulateCities() {
        debugger;
        var State = $("#ddlState").val();
        GetCities(State);
        return false;
    }
    function GetCities(StateId) {
        debugger;
        var v1 = 'StateId: ' + StateId;
        $.ajax(
     {
         type: "POST",
         url: 'DropDownList_Cascade.aspx/PopulateCities',
         data: '{' + v1 + '}',
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function (result) {
             if (result.status === "OK") {
                 alert('Success!!');
             }
             else {
                 fnDisplayCities(result);
             }
         },
         error: function (req, status, error) {
             alert("Sorry! Not able to retrieve cities");
         }
     });
 }
</script>

This is my serverside method which i need to call.

private static ArrayList PopulateCities(int StateId)
{
    //this code returns Cities ArrayList from database.
}

It is giving me the following error: 500 (Internal Server Error)

I cannot figure out what is wrong. please help!

Stack Trace:

[ArgumentException: Unknown web method PopulateCities.Parameter name: methodName]

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery