JQUERY ajax passing null value from MVC View to Controller
Posted
by
Piyush Sardana
on Stack Overflow
See other posts from Stack Overflow
or by Piyush Sardana
Published on 2012-06-22T08:20:01Z
Indexed on
2012/06/22
9:16 UTC
Read the original article
Hit count: 180
hi guys i'm posting some data to controller using jquery ajax, but i am getting null values in my controller,
jQuery code is:
$('#registerCompOff').click(function() {
var compOff = [];
$('div').each(function() {
var curRow = {};
curRow.Description = $(this).find('.reason').val();
curRow.CompOffDate = $(this).find('.datefieldWithWeekends').val();
if (curRow.Description != null && curRow.CompOffDate != null) {
compOff.push(curRow);
}
});
$.ajax({
type: 'POST',
url: this.href,
dataType: 'json',
data: compOff
});
return $('form').valid();
});?
compOff
is not null I have checked that...
controller is:
[HttpPost]
public ActionResult RegisterCompOff(RegisterCompOff[] registerCompOff)
{
//return View();
}
can you tell me where i'm going wrong?
© Stack Overflow or respective owner