Код: Выделить всё
$('#salvaprod').on('click', function() {
$.ajax({
type: 'post',
url: 'lcompras_add_sql.php',
datatype: 'html',
data: {
qtdp: $('#qtdp').val(),
produtop: $('#produtop').val(),
}
}).done(function(data) {
requisitarPagina('')
})
})
function requisitarPagina(url) {
let ajax = new XMLHttpRequest();
ajax.open('POST', url)
ajax.onreadystatechange = () => {0
if(ajax.readyState == 4 && ajax.status == 200) {
parent.jQuery.fancybox.close();
html='[i][/i] '+$('#qtdp').val()+'x '+$('#produtop').val()+'';
$("#listac").append(html);
$('#qtdp').val()='1';
$('#produtop').val()='';
$.wnoty({
// 'success', 'info', 'error', 'warning'
type:'success',
message:'Produto adicionado com sucesso',
autohideDelay: 5000,// 5 seconds
// "top-left", "bottom-left", "top-right", "bottom-right"
position:'top-right',
});
alert (html);
}
if(ajax.readyState == 4 && ajax.status == 404) {
//document.getElementById('resultado').innerHTML = '.. tente novamente mais tarde :s ..'
// document.getElementById('modal').style.visibility = 'hidden'
parent.jQuery.fancybox.close();
$.wnoty({
// 'success', 'info', 'error', 'warning'
type:'error',
message:'Produto não incluido, tente novamente',
autohideDelay: 7000,// 5 seconds
// "top-left", "bottom-left", "top-right", "bottom-right"
position:'top-right',
});
}
}
ajax.send()
console.log(ajax)
}
Пробывал много разные синтаксисы, пробовал даже alert, непосредственно перед добавлением, но это тоже не сработало.
Подробнее здесь: https://stackoverflow.com/questions/786 ... x-function