I was created a function that is responsible to created and sending a json :
function Send(op) {
var tr = $(op).parents('tr');
var item = [];
$(tr).find("td").each(function () {
item.push($(this).find("input").prop("name") + '":' + '"' + $(this).find("input").val());
});
var myJsonString = JSON.stringify(item);
$.ajax({
url: '/Home/Edit',
data: myJsonString,
type:'post',
contentType: 'application/json; charset=utf-8',
cache: false,
success: function () {
alert('send is okay')
}
});
}
to an IActionResult :
[HttpPost]
public ActionResult Edit([FromBody]Hazine hazine)
{
return View();
}
but it (Edit Action) cant get object from jquery. so this Action Invoked Succcefully but with null hazine!
a json created which I get from console.log is :
["id\":\"4","undefined\":\"undefined","undefined\":\"undefined","HazineType1\":\"1","HazineType2\":\"1","SendDate\":\"5","ProjectId\":\"1","Mablagh\":\"1","MablaghPaid\":\"1","HazineDate\":\"1","HazineDateLong\":\"1","HazineTitle\":\"11111","HazineComment\":\"1","ForoshgahName\":\"1","PayLastDate\":\"1","PayDateLong\":\"111111111","UniqueId\":\"1111","SaveDate\":\"8888","SaveDateLong\":\"888","SendDate\":\"5","SendDateLong\":\"5"]
what was wrong?
Console Log:
It Work:
It not work:
in second function cant call and err 500 occure