Rahul Lakshakar

Rahul Lakshakar

  • 1.7k
  • 168
  • 12.4k

Pass Model data from view to controller using ajax

Nov 15 2018 11:07 PM
Hello Sir,
 
I am trying to pass model data from view  to controller but it's not working. Infact it's not firing the action in controller.
 
Please help and guide me.
 
Thanks
 
 
My Code like this:
 
 
#MODEL
public class model{
report objReport = new report();
model = new model()
{
   objReport = new report();
}
}
 
public class reoprt{
public int reportID {get;set;}
}
 
#CONTROLLER
 
public string save(model objModel)
{
return "done";
}
 
 
#AJAX CALL
var objDailyReport = $("#CNform").serialize();

$.ajax({
type: "POST",
url: "/dailyreportingregister/Save",
data: objDailyReport,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
alert("done");
}
}); 
 
 
 
 

Answers (3)