1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| function getXhr() {
var xhr = null;
if (window.XMLHttpRequest){
xhr = new XMLHttpRequest();
}
else if(window.ActiveXObject){
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else { //pas de support
alert("Pas de support pour XMLHttpRequest");
}
return xhr;
}
function go(){
var xhr = getXhr();
xhr.onreadystatechange = function(){
if(xhr.readystate == 4 && xhr.status == 200){
//ce que je dois faire quand c OK (ici un test d'affichage en attendant)
document.getElementById('plop').style.display = 'block';
}
};
//le web service que j'appelle
xhr.open("GET", "http://localhost/WebServiceHTTP/Service1.asmx/addInteger?a=10&b=8", true);
xhr.send(null);
} |
Partager