async function waitForElement( selector, timeout = 5000, interval = 100 ) {
return new Promise( ( resolve, reject ) => {
check( resolve, reject, timeout )
} );
function check( res, rej, to ) {
if( to < 0 ) {
rej();
return;
}
const el = document.querySelector( selector );
if( el ) {
res( el );
return;
}
setTimeout( check, interval, res, rej, to - interval );
}
}
$.post("/cart/countAjax/" + id, {}, function (data) {
$("#cart-count").html(data);
$.post("/cart/productPriceAjax/" + id, {}, function (data) {
$("#product-price-cart" + id).html(data);
$.post("/cart/totalPriceAjax/" + id, {}, function (data) {
$(".total-price-cart").html(data);
});
});
});