Код: Выделить всё
$('#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)
parent.jQuery.fancybox.close();
ajax.onreadystatechange = () => {
if(ajax.readyState == 4 && ajax.status == 200) {
// add no extrato
alert("ttt"); //Alert doesnt work
html='[i][/i] '+$('#qtdp').val()+'x '+$('#produtop').val()+'';
$("#listac").append(html);
document.getElementById('qtdp').value = '1'; //Values not reseted
document.getElementById('produtop').value = '';//Values not reseted
$.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);
console.log(html) //does not log
}
if(ajax.readyState == 4 && ajax.status == 404) {
//document.getElementById('resultado').innerHTML = '.. tente novamente mais tarde :s ..'
// document.getElementById('modal').style.visibility = 'hidden'
$.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)
}
Пробывал много разные синтаксисы, пробовал даже предупреждение, непосредственно перед добавлением, но это тоже не сработало.
он сохраняет запрос @ базу данных, показывает wnoty в случае успеха, но не делает этого запустить оповещение, добавить или установить значение.
Подробнее здесь: https://stackoverflow.com/questions/786 ... x-function