Click here to Skip to main content
15,742,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am newbie to MVC tech. I want to call a simple method of a controller. Here it is what I did so far.

on change event of dropdownlist I am calling the controller's function.

    $(document).ready(function () {
        $('#ChangeStatus').change(function () {

            var selectVal = $('#ChangeStatus option:selected').val().toString();
            var selecttext = $('#ChangeStatus option:selected').text().toString();

                type: "GET",
                url: '@Url.Action("demo", "displayDemo")',
                contentType: "application/json",
                dataType: 'json',
                data: { dispID: selectVal },
                success: function (response) {
                //alert('Calling function successfuly');
                var returnValue = response.ReturnValue;



"demo" is my method accepting one string parameter and returning another string. and "
" is the controller's name.

in controller I have

       public string demo(string dispID)
          string msg="showing "+dispID;
          return msg;

After executing it, I am not getting desired result back. I am sure I am missing something. please help me to figure it out.

It's showing me error like
0x800a138f - JavaScript runtime error: Unable to get property 'ReturnValue' of undefined or null reference

1 solution

Hi :)

In controller try this code.

       public string demo(string dispID)
          string msg="showing "+dispID;
          return msg;

This should work here
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