I am using ASP.net pagemethods. This issue I am having is that it wont work with certain browsers. e.g IE, Opera Safari and the new Firefox. It works with Chrome. I found this but didn't help in my case http://www.carlj.ca/2008/06/18/fixing-firefoxs-ns_error_not_available-error-when-using-pagemethods/ any help would be much appreciated.
<asp:ScriptManager ID=”scManager″ enablepagemethods=”true” runat=”server” />
<asp:Button ID="btnBuyNow" runat="server" Text="Buy Now" OnClientClick="AddProductToCart()" />
<script type="text/javascript">
function AddProductToCart() {
//hard coded values for testing, productId, quantity
PageMethods.AddProduct(142, 1);
window.location.href = '../Cart.aspx';
}
</script>
[System.Web.Services.WebMethod]
public static void AddProduct(string prodId, string quantity)
{
//adding product to cart
//When testing with Chrome breakpoint is hit,
//All other browsers dont hit break point
CurrentCart.AddProduct(prodId, quantity);
}
There might be a better solution to this but this was the only thing that eventually worked.
<script type="text/javascript">
function AddProductToCart() {
//hard coded values for testing, productId, quantity
PageMethods.AddProduct(142, 1);
var millisecondsToWait = 500;
setTimeout(function () {
window.location.href = '../Cart.aspx';
}, millisecondsToWait);
}
</script>