I want to send class as post ajax parameters.
my class :
public class PageInput
{
public string ActionName { get; set; }
public string Controller { get; set; }
public int CountPage { get; set; }
public int CountRecordInPage { get; set; }
public KeyValuePair<string, short> No { get; set; }
}
ajax code :
$.ajax({
url: '@Url.Action("GetPageNumbers", "MyClasses")',
data: '@Model.PageInput',
success: function (data) {
alert(data);
}
});
action :
public ActionResult GetPageNumbers(PageInput pageInput)
{
return PartialView("_PagingNumbers", pageInput);
}
doesn't working. But why?
When data are received by the actionResult are empty!!But the data are correct before sending.
$.ajax()type is'GET', so you'd need to set that to'POST'if you're expecting only posted data.