At the moment I have a jQuery do a POST to a Controller which returns a ContentResult. When the OnSuccess event fires from jQuery it updates a div with the returned data. I now want to update another DIV with model data.
I am thinking have a RenderPartial in my view, do the post and return a PartialResult which will handle this new div but what about the DIV I was previously populating?
Is combining a JavaScriptResult and a PartialResult possible? The JavaScript result handles the first DIV I mentioned and the PartialResult the new DIV.
Thanks
This is how I have done it.
My main view now does a RenderPartial(“PartialViewName”,Model).
At the top of the Partial view I check if ViewData[“AJAXReturn”] is not null. If it isn’t I call another Partial view and pass in the ViewData[“AJAXReturn”] item that contains the original AJAX response.
In my Controller action method I add my original response message to ViewData[“AJAXReturn”], I then call methods to update my model data and do a return PartialView(“PartialViewName”,UpdatedModel).
Now the ViewData is not null so the original DIV is populated via ViewData and calling PartialView with the new model renders the second DIV. This is done by the OnSuccess event in the jQuery post which does $(‘#containingdiv’).html(responsefromPartialViewreturn);
Hope this helps someone.