I'd like to update my html template with the data I have retrieved through an AJAX call.
I can fetch the data and define variables in JS. However, how do I get the value from JS to Html, to update the value within the Html "pill"?
0
i.e. change the value from 0 to the value that is defined in var CarPrice = data.carPrice; ?
JS:
$(function () {
var getProduct) = function () {
var btn = $(this);
$.ajax({
url: btn.attr("data-url"),
type: 'get',
dataType: 'json',
success: function (data){
var CarMake = data.carMake
var CarPrice = data.carPrice
$("#CarMake").val(CarMake);
$("#CarPrice").val(CarPrice);
}, error: function(error){
console.log(error)
console.log("error")
}
});
};
$(".js-get-product").click(getProduct);
});
HTML (django):