I tried everything to send the form back to my controller using ajax.
I simplified my model for strings only.
- ajax correctly displays all form data.
- I have serilaizeArray ().
My object, called the model, is null every time (other parameters are displayed just fine, that is, the page, sorting ...). What am I missing?
Ajax:
... var model = $('#advancesearchform').serialize(); var request = $.ajax({ type: "POST", url: "/DAM/Home/_ImageSearchResult", cache: false, traditional: true, contentType: 'application/json; charset=utf-8', dataType: 'json', data: JSON.stringify({ page: page, itemsperpage: itemsperpage, sort: sort, sortdir: sortdir, model: model }), success: function (data) { $('#imagesearchresults').html(data); } });
JSON.stringfy:
{\ "Page \": null, \ "itemsperpage \": 8, \ "type \": \ "Project \", \ "sortdir \": \ "ASC \", \ "model \": \ "FileName = 123 & OriginalFileName = & SAS of the amplifier; height = ACAC & Width = ACAC & DepartmentID = 9b4463cd-C184-e211-9244-005056887208 & ClassID = 28de9d15-c284-e211-9244-005056887208 \ "}
Controller:
[HttpPost] public PartialViewResult _ImageSearchResult(int? page, int itemsperpage, string sort, string sortdir, AdvanceSearchFilters model) { }
Model:
public class AdvanceSearchFilters { public string FileName { get; set; } public string OriginalFormat { get; set; } public string Width { get; set; } public string Height { get; set; } public string MediaSource { get; set; } public string DepartmentId { get; set; } public string ClassId { get; set; } public string ThemeId { get; set; } }