Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to make an ajax call for a purpose, but parameters always null when I receive in controller

What I have tried:

$.ajax({
        url: "Employee/CreateEmployee",
        type: 'GET',
        data: {"Name":"Jonson","Designation":"Engineer"},
        contentType: 'application/json; charset=utf-8',
        success: function (response) {
            alert(response.status);
        },
        error: function () {
            alert("error");
        }
    }); 
Posted
Updated 5-Aug-17 23:17pm

1 solution

Pass your parameters as following:

data: {Name:"Jonson",Designation:"Engineer"},


and name of parameters in Ajax should be same in MVC controller method.
 
Share this answer
 
Comments
Muhammad-Mughal 6-Aug-17 5:46am    
Thanks it's worked
[no name] 6-Aug-17 5:49am    
That's good.

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