I have the following JavaScript code:
$(document).ready(function () {
$("#customers .js-delete").on("click", function () {
if (confirm("Are you sure you want to delete this customer?")) {
$.ajax({
url: "api/customers/" + $(this).attr("data-customer-id"),
method: "DELETE",
success: function () {
console.log("Success");
}
});
}
});
});
When I run it, I receive the following error in the console:
jquery-3.5.1.js:10099 DELETE https://localhost:44367/Customers/api/customers/5 404
The issue is the API call should look like https://localhost:44367/api/customers/5
.
How do I fix this issue?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…