I use the simple AJAX and use google debug then find that the url is not exist...
The code is very simple:
var http;
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
http=new XMLHttpRequest();
} else {
http=new ActiveXObject("Microsoft.XMLHTTP");
}
try {
http.open("GET", 'http://'+ip+':5000/test.html', true);
http.onreadystatechange = onRcvData;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
http.send(null);
} else {// code for IE6, IE5
http.send();
}
} catch(e) {
http.abort();
}
function onRcvData() {
if (http.readyState==4) {
if (http.status==404) {
} else if(http.status==200) {
} else {
}
}
}
It's okay if the file test.html exists. When the file isn't exist, the error show in the part:
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
http.send(null);
} else { // code for IE6, IE5
http.send();
}
So, even if I use the onreadystatechange method cannot prevent the error...
The file is in a directoy beside my web pages.
Then what should I do to combine with httprequest?
Any advice appreciate.
Add:
I have used the method 'Head' but it is return 404... (No matter jQuery plugin/javascript)
Like the picture:
What should I do...
Is the direction of the error I found misleaded?