I do not think that I get Ajax functions in mvc because I get this strange problem.
I got the following code that makes my ajax call, it is placed in a partial view using productList:
<% using(Ajax.BeginForm("AddToBasket", "Basket",
new { productID = item.Id },
new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "Basket", OnSuccess = "productAdded(" + item.Id + ")" })) { %>
<input type="image" src="/Content/addToCart.png" />
<% } %>
I have <div id="Basket"></div>on my main page
And this method in BasketController, which returns a partial view, which is in Basket / BasketList.ascx:
[HttpPost]
public ActionResult AddToBasket(int productID)
{
return PartialView("BasketList");
}
When I logged in using asp.net's default membership, everything works fine, it updates the basket, and it is all asynchronous, but when I log out and click on addToCart, it redirects me to Basket / AddToBasket? productID = 1, which is a partial view.
Does anyone know why this is happening?
I have a similar problem with ajax.actionlink
<%= Ajax.ActionLink("Gem", "SaveBasket", "Basket", new AjaxOptions { HttpMethod = "Post" })%>
: " ". , BasketController
[HttpPost]
public void SaveBasket()
{
}