I have this Ajax code running on my web page (asp.net razor)
$(document).on('click', '#search-results tr', function (event) {
//Add to cart
var id = $(this).find('#SKU').val();
var userId = $('#ID').val();
$.ajax({
url: "/orders/AddtoCart",
type: 'POST',
cache: false,
dataType: 'json',
data: { "productId": id, "Quantity": 1, "UserID": userId, "Description": "" },
success: function (data) {
console.debug("Added to cart");
//ajax call to DraftOrderDetailsLineItems to refresh the lines
$.get('/Orders/DraftOrderDetailsLineItems/', { customerId: data.id }, function (data) {
$("#draftOrderItems").html(data);
})
},
error: function (jqXHR, textStatus, errorThrown) {
console.error("[Error in Ajax Request, Add To Cart] Code:" + jqXHR.status + " Error:" + errorThrown + "
Text Status:" + jqXHR.responseText);
}
});
});
I put a breakpoint in my controller and it is calling the AddtoCart method just fine. However when I look in my console I am getting this error:
VM247 DraftOrderDetails.js:19 [Error in Ajax Request, Add To Cart] Code:0 Error: Text Status:undefined
I have been looking this over and I just can't seem to find out what is going one.