I tried to make a call from jquery to asp.net webmethod.But it never get invoked from Jquery.
[WebMethod]
public void AddProductToCart(int productid)
{
Response.Write(productid.ToString());
MyShoppingCart usersShoppingCart = new MyShoppingCart();
String cartId = usersShoppingCart.GetShoppingCartId();
try
{
usersShoppingCart.AddItem(cartId, productid, 1);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
Jquery function
function d(t) {
e.ajax({
url: "productmodel.aspx/AddProductToCart",
type: "POST",
data: JSON.stringify(t),
dataType: "json",
contentType: "application/json; charset=utf-8",
sucess: function () {
alert("added to cart successfully");
}
})
}
Please help me to resolve the issue.