作者:12sadad | 来源:互联网 | 2023-09-16 06:01
12345678910111213141516171819202122232425262728293031/** * ajax库 */// global variables to keep track
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
| /**
* ajax库
*/
// global variables to keep track of the request and the function to call when done
var ajaxreq = false,ajaxCallback;
// ajaxRequest: Sets up a request
function ajaxRequest(filename) {
try {
// Firefox /IE7 /Others
ajaxreq = new XMLHttpRequest();
} catch (error) {
try {
// IE5 / IE6
ajaxreq = new ActiveXOject("Microsoft.XMLHTTP");
} catch (error) {
return false;
}
}
ajaxreq.open("GET",filename);
ajaxreq.Onreadystatechange= ajaxResponse;
ajaxreq.send(null);
}
// ajaxResponse: Waits for response and calls a function
function ajaxResponse(){
if(ajaxreq.readyState != 4) return;
if(ajaxreq.status == 200) {
// if the request succeed...
if(ajaxCallback) ajaxCallback();
}else alert("Request failed: " + ajaxreq.statusText);
return true;
} |
开头的var ajaxreq = false,ajaxCallback;是声明ajaxreq对象吗?ajaxCallback在这个地方是什么意思?初学Javascript,请前辈指教哈
function ajaxResponse(){
1 2 3 4 5 6
| if(ajaxreq.readyState != 4) return;
if(ajaxreq.status == 200) {
// if the request succeed...
if(ajaxCallback) ajaxCallback();
}else alert("Request failed: " + ajaxreq.statusText);
return true; |
}
请大神帮忙解释下这个4 和 200吧?还有别的值吗?