2013-11-21 6 views
5

मैं div है कि अपने पन्ने पर छवि गैलरी rendersताज़ा html.renderaction

 <div id="gallery">  
    @{ 
     Html.RenderAction("UserGallery"); 
    } 

मैं इस समारोह जो एक नई छवि का एक सफल अपलोड के पूरा होने पर चलता है

 function filesUploadOnSuccess(e) { 
      function updateCart() { 
       //var tdata = $(frm).serialize(); 
       // or your data in the format that will be used ?? 
       $.ajax({ 
        type: "GET", 
        //data: tdata, 
        url : '@Url.Action("UserGallery")', 
        dataType: "json", 
        success: function (result) { success(result); } 
       }); 
      }; 
     } 

     function success(result) { 
      $("#gallery").html(result); 
     } 

समस्या यह है कि गैलरी div अद्यतन नहीं होता है।

उत्तर

5

dateType, "html", नहीं "json" होना चाहिए अपनी कार्रवाई एक PartialViewResult वापस लौट आता है:

public ActionResult UserGallery() 
{ 
    // do something 
    return PartialView();  
} 

और

$.ajax({ 
    url : '@Url.Action("UserGallery")', 
    dataType: "html", 
    success: function (result) { success(result); } 
}); 
संबंधित मुद्दे