Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model SIServices.ViewModels.SODViewModel
- @using (Html.BeginForm("Initiate", "SOD", FormMethod.Post, new { id =
- "initiateSOD" })) // enctype = "multipart/form-data"
- {
- @Html.AntiForgeryToken()
- ...
- @* form inputs as html helpers *@
- @* html table data is collected as json *@
- var cols = [];
- cols.push("DIGITAL_FILE_TYPE_ID");
- cols.push("DOCUMENT_LAPI_ID");
- var DigitalMaps = [];
- $("table#digital-map-table tbody tr").each(function () {
- data = {};
- var selectedDigitalMapVal = $(this).data("selectedDigitalMapVal");
- data[cols[0]] = selectedDigitalMapVal;
- var documentId = $(this).data("documentID");
- data[cols[1]] = documentId.toString();
- DigitalMaps.push(data);
- data = {};
- });
- var headers = { __RequestVerificationToken:
- $('input[name="__RequestVerificationToken"]').val() };
- if (DigitalMaps != null) {
- $.ajax({
- headers: headers,
- url: "@Url.Action("Initiate")",
- type: "POST",
- cache: false,
- contentType: "application/json; charset=utf-8",
- data: DigitalMaps,
- dataType: "json",
- success: function (succ) {
- console.log(succ);
- },
- error: function (err) {
- console.log(err.statusText);
- }
- });
- }
- namespace SIServices.ViewModels
- {
- public class SODViewModel
- {
- // a lot of properties - around 50
- public int? DigitalMapId { get; set; }
- public List<DIGITAL_MAPS> DigitalMaps { get; set; }
- [HttpPost]
- [ValidateHeaderAntiForgeryToken]
- public ActionResult Initiate(SODViewModel vm)
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement