I know little of Javascript but have managed to assemble a code for an ajax request on my web site but now find it is only working on Mozilla/Firefox. My code is:
function ajaxFunction(char){
var ajaxRequest;
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
if(this.status !==200){
**alert("Error: Status '+this.status+' returned.");**
}else{
document.getElementById('directory').innerHTML= ajaxRequest.responseText;
}
}
}
var namevalue=char
ajaxRequest.open("GET", "../directory pagtestAug.php?name="+namevalue, true);
ajaxRequest.send(null);
}
I am also making use of:
src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js">
(although I am not sure what this does - I am finding it difficult to find javascript tuition beyond the very basic)
The response is Error :Status'+this.status+' returned.
I have seen many posts on the 200 status but none on what to do if the server does not respond. Is there another code to use or a different one for each browser ? Thank you for taking the trouble to read this (and reply, please)