KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Ajax function $(function () { $('form').submit(function () { if ($(this).valid()) { $.ajax({ url: this.action, type: this.method, data: { model: $(this).serialize(), locations: getCheckedLocation(), reports: getCheckedReports() }, beforeSend: function () { }, complete: function () { }, success: function (result) { $('#user_operations_container').html(result); setTimeout(function () { LoadAction('@Url.Action("GetAllUsers", "User")') }, 1000); $("#widgets ul li a").removeClass("link_active"); $("#widgets ul li:first-child a").addClass("link_active"); } }); } return false; }); }); functions that are using in ajax data attribute function getCheckedLocation() { var nodes = $('#tt_location').tree('getChecked'); var s = ''; for (var i = 0; i < nodes.length; i++) { if (s != '') s += ','; s += nodes[i].text; } return s; } function getCheckedReports() { var nodes = $('#tt_reports').tree('getChecked'); var s = ''; for (var i = 0; i < nodes.length; i++) { if (s != '') s += ','; s += nodes[i].text; } return s; } HTML <div> // there are html helpers for model (dropdownlistfor, textboxfor,...) </div> <div> // checkbox tree (#tt_location) </div> <div> // checkbox tree (#tt_reports) </div> Controller [HttpPost] public ActionResult _EditUser(UserViewModel model,string locations,string reports) { // model = null // locations and reports are expected. (not null) } Question Why model is null? When I use ajax data attribute like this =
Tags (comma-separated)
Save Edits
Cancel