Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want write java script document.ready function for call controller name and action name.in Mvc4.0 cshtml page.please send answer to me.
Posted

1 solution

Hi Venki,

You can use ajax call to MVC controller action like this
$('#ddlName').change(function () { 
    var parametervalue = $('#ddlName option:selected').val(); 
    $.ajax({ url: 'FillResources', type: 'POST',  //Give controller name/index name as URL
        data: JSON.stringify({ parameter: parametervalue }), //Parameter
        dataType: 'json', contentType: 'application/json', 
        success: function (result) { 
            //Enters if its success
        },
		error: function (){
		 //Enter if any error occurs
		}	
    });
});

Note: Above action method should have [HttpPost] attribute
Hope this helps you a bit.

Regards,
RK
 
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