Bonjour,
voici mon code pour faire mes requête AJAX :
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
// creation d'une classe
function ObjAjaxEx(){
// propriétés/méthodes de l'objet
this.methode = "GET"
this.url = null
this.dataToSend = null
this.callBackFuncRecieveRequest = null
this.startTime = null
// variables locales
var xhr = null
// creation d'une methode
this.run = function() {
if(window.XMLHttpRequest){
xhr = new XMLHttpRequest()
xhr.onreadystatechange = recieveRequest
xhr.open(this.methode, this.url, true)
xhr.send(this.dataToSend)
} else if(window.ActiveXObject){
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP")
}
if(xhr) {
xhr.onreadystatechange = recieveRequest
xhr.open(this.methode, this.url, true)
xhr.send(this.dataToSend)
}
} else {
alert("Votre Navigateur Internet ne supporte pas XMLHttpRequest")
}
this.startTime = new Date().getTime()
}
function recieveRequest(){
if(xhr){
if(xhr.readyState == 4){
if(xhr.status == 200) {
eval(xhr.responseText)
this.callBackFuncRecieveRequest(this)
}
}
}
}
}
function myCallBackFunction(obj_ObjAjaxEx){
alert("requete reçue" + obj_ObjAjaxEx.startTime)
}
var myObj = null
// lancement du programme
function startScript(){
//for(i=0; i<10; i++){
myObj = new ObjAjaxEx()
myObj.url = "http://www.ietf.org/rfc/rfc768.txt"
myObj.callBackFuncRecieveRequest = myCallBackFunction
myObj.run()
//}
} |
=> je lance la fonction startScript avec
<body onload="startScript()">
j'ai l'erreur : 206 Partial Content 1.66s
=> de quoi peut venir le probleme ?
merci d'avance
Partager