I am try to get my onClick to work however my when I click nothing happens and no error to give insight as to what the problem might be
var data = new FormData();
data.append("cart_list", new_cart);
$.ajax({
url: "@Url.Action("GetCart", "Home")",
type: "POST",
processData: false,
contentType: false,
data: data,
success: function (result) {
//code after success
var html = "";
// var removeIndex
for (index = 0; index < result.result.length; ++index) {
removeIndex = result.result[index];
html = html + '<li class="minicart-product">' + result.result[index].HFR +;
Html = Html + ' <a class="product-item_remove" onclick="RemoveFromCart()"></a>';
html = html + '<i class="ion-android-close"></i>';
html = html + '</a>';
html = html + '<div class="product-item_img">';
html = html + '<img src="../Content/assests/images/Catalogue/' + result.result[index].Foto + '" alt="../Content/assests/images/Catalogue/default.png">';
html = html + '</div>';
html = html + '<div class="product-item_content">';
html = html + '<a class="product-item_title" href="">' + result.result[index].TractorModel + " " + result.result[index].Description + '</a>';
html = html + '<span class="product-item_quantity">' + result.result[index].HFR + '</span>';
html = html + '</div>';
html = html + '</li>';
}
$("#myCart").html(html);
},
error: function (er) {
alert(er.responseText);
}
});
}
function RemoveFromCart()
{
alert("Remove me")
}
It is html not Html.
Replace this line :
Html = Html + ' <a class="product-item_remove" onclick="RemoveFromCart()"></a>';
with
html = html + ' <a class="product-item_remove" onclick="RemoveFromCart()"></a>';