I have a method to get all the products
function listProducts() {
$.get("./listProducts", function(data) {
data.forEach(function(item) {
var $clone = $('#product').clone().removeAttr('id');
$clone.find('.productName').text(item.nameEn);
$clone.appendTo('#rowProducts');
});
});
};
I have another method to add a product, i want when adding a new product, in the success method it does reload to the previous method listProducts() to get the new product list
$(document).ready(function() {
$('#validProduct').on("click", function(e) {
......
$.ajax({
type : "POST",
contentType : "application/json",
url : "./addProduct",
data : JSON.stringify(product),
dataType : 'json',
timeout : 6000,
success : function(data) {
/* **reload listProducts** */
}
});
});
});