JQuery pass model to controller

Posted by slandau on Stack Overflow See other posts from Stack Overflow or by slandau
Published on 2011-02-24T15:22:56Z Indexed on 2011/02/24 15:25 UTC
Read the original article Hit count: 158

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX