Come è possibile rilevare se una richiesta Ajax non è riuscita a caricare un file.Rileva se la richiesta Ajax non è riuscita in JavaScript
Ecco il mio codice di riferimento:
var pro = undefined;
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
pro = JSON.parse(xmlhttp.responseText);
}
}
xmlhttp.open("GET","data.json",true);
xmlhttp.send();
Per favore, no jQuery.
Grazie!
No jQuery? Ho una buona idea di non votarti! –
@SteveWellens Perché un voto negativo? Voglio solo evitare di usare jQuery. – Progo
Evitare jQuery è come evitare la ruota. jQuery ti aiuta. (Stavo scherzando, non ho votato). –