2016-12-28 40 views
0

我試圖將多個對象傳遞給我的jQuery後的數據對象是這樣的:MVC多個對象返回jQuery的POST數據

return View("AffiliateManager", /*and now pass the JSON flag here*/); 

的「JSON標誌」將只是這樣的:

Json("Ok"); => signaling that call was success 
所以,現在

.done(function (data) { 
        if (data == "ErrorRequest") { 
         ShowErrorMessage("You don't have enough money to request payment!"); 
         $('.btnRequestPayout').prop('disabled', false); 
         return; 
        } 
        else if(data=="Ok"){ 
         ShowMessage("Payment request successfully made."); 
         $('.btnRequestPayout').prop('disabled', false); 
         var wholePage = $('<div />').append(data).find('#divPage').html(); 

         $('#divPage').html(wholePage); 
        } 
       }); 

所以,我可以抓取網頁,並在我的jQuery的崗位數據「確定」參數的兩個HTML對象這樣我有這樣的數據對象:

data.html => whole HTML of the page 
data.flag => signal whether the call was good 

我該如何在.NET MVC中實現這一目標?

+1

看到這個[從ASP.NET MVC操作返回管窺和JSON(http://stackoverflow.com/questions/18667447/return-partial-view-and-json-from-asp-net- MVC-動作) – Shyju

回答

1

你可以試試這段代碼;

Json(new { html = "Html String Here" , flag = "Ok" } , JsonRequestBehavior.AllowGet);