JQuery pass model to controller
- by slandau
I want to pass the mvc page model back to my controller within a Javascript Object. How would I do that?
var urlString = "<%= System.Web.VirtualPathUtility.ToAbsolute("~/mvc/Indications.cfc/ExportToExcel")%>";
var jsonNickname =
{
model: Model,
viewName: "<%= VirtualPathUtility.ToAbsolute("~/Views/Indications/TermSheetViews/Swap/CashFlows.aspx")%>",
fileName: 'Cashflows.xls'
}
$.ajax({
type: "POST",
url: urlString,
data: jsonNickname,
async: false,
success: function (data) {
$('#termSheetPrinted').append(data);
}
});
So where it says model: Model, I want the Model to be the actual page model that I declare at the top of the page:
Inherits="System.Web.Mvc.ViewPage<Chatham.Web.Models.Indications.SwapModel>"
How can I do that?