I'm using a function in ajax
to make some dynamic requests, but req.status
is returning 0
instead of 200
.
What can it be?
Below the code:
if(window.XMLHttpRequest) {
req = new XMLHttpRequest();
}
else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
// Arquivo PHP juntamente com o valor digitado no campo (metodo GET)
var url = "http://177.55.99.146:8080/autenticacao/autentica?arquivo="+file;
// Chamada do metodo open para processar a requisicao
req.open("Get", url, true);
// Quando o objeto recebe o retorno, chamamos a seguinte funcao;
req.onreadystatechange = function() {
alert("Retorno do readyState == " + req.readyState + " readyStatus == " + req.status);
if(req.readyState == 1) {
alert("Entrei no readyState == 1");
}
if(req.readyState == 4 && req.status == 200) {
alert("Entrei no readyState == 4 e status == 200");
// Resposta retornada pelo busca.php
var resposta = req.responseText;
}