I've searched for hours and I just do not have an idea of how to solve this.
I have a Winkelwagen Controller:
[ChildActionOnly]
public ActionResult WinkelwagenPartial()
{
// Get the content of the cart
OrderregelLijst winkelwagenInhoud = new OrderregelLijst
{
Orderregels = (List<Orderregel>)Session["winkelwagen"]
};
return PartialView(winkelwagenInhoud);
}
I load the Partial View in my main layout like this:
<div id="winkelwagenContainer">
@{
Html.RenderAction("WinkelwagenPartial", "Winkelwagen");
}
</div>
This all works fine, the problem now is: How do I refresh my partial view after the content of the shopping cart changes?
I've written the following in jQuery:
$.ajax({
url: '/WinkelWagen/WinkelwagenPartial',
success: function (data) {
alert(data);
}
});
When I add something to the cart or delete something from it, I want the partial view to update. I get the following error though:
The action 'WinkelwagenPartial' is accessible only by a child request.
Which I can understand, since partial views can't be located directly. My question now is though, how can I possibly refresh my partial view?