Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When creating ajax call to controller getting 2nd parameter only.

JavaScript
return $http({
          method: "post",
          url: "/myform/AddEmployee",
          data: '{ "EmpDetail":' + JSON.stringify(employee) + ', "File_ID":' + File_ID + '}',
          //data: JSON.stringify(employee,File_ID),
          dataType: "json"
      })


Controller:-

C#
public string AddEmployee(EmpDetail Emp, int? File_ID)
      {
       ....
}


What I have tried:

data: JSON.stringify(employee,File_ID)

after using this getting first parameter only.
Posted
Updated 30-Jun-16 0:23am
Comments
Richard Deeming 28-Jun-16 12:12pm    
How about:
data: JSON.stringify({ "EmpDetail": employee, "File_ID": File_ID })
Karthik_Mahalingam 29-Jun-16 1:51am    
post the class for EmpDetail

1 solution

I got the solution.

I was passing parameters with different names.

The call should be like that:-

var empData= JSON.stringify({ Emp: employee, File_ID: File_ID });
 
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