Erro em AJAX: retornando OK
ALGUÉM PODERIA ME DIZER SE HÁ ALGUM ERRO COM O CÓDIGO ABAIXO. NA MINHA OPINIÃO NÃO HÁ, MAS ESTÁ RETORNANDO "OK", ISSO MESMO, A STRING OK, E NÃO ESTÁ TUFANDO. NÃO SEI O PORQUE. ALGUÉM ME DARIA UMA LUZ.OBRIGADO.var req;function excluiNoticia(id){ url = 'exclui_not.php?id='+id; req = null; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = excNoticia; req.open("GET", url, true); req.send(null); } else if (window.ActiveXObject) { try { req = new ActiveXObject("Msxml2.XMLHTTP.4.0"); } catch(e){ try { req = new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch(e) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { req = false; } } } } if (req) { req.onreadystatechange = excNoticia; req.open("GET", url, true); req.send(); } }}function excNoticia(){ if (req.readyState == 4) { if (req.status == 200) { if(req.statusText=="EXC"){//se tudo der certo na exclusão no script, ele retorna EXC para o JAVASCRIPT window.alert('Exclusão efetuada'); } else window.alert(req.statusText); } else { alert("Houve um problema ao obter os dados:\n" + req.statusText); } }}
Discussão (2)
Carregando comentários...