Played with the tutorials @ http://www.w3schools.com/Ajax/ to get my head rounds the basics. Trying to slightly amend the basic examples here so it happens when a button is pressed instead.
It's a simple form with 1 text box where you enter a domain. When you hit submit it should throw out the whois result returned by whois.php.
It works in IE7, but not Firefox though. I've put the alerts in to help debug, and it does come up saying "Your browser is Opera, Firefox, or Safari". The output is then blank though.
whois.js:
Thanks,
Shell
It's a simple form with 1 text box where you enter a domain. When you hit submit it should throw out the whois result returned by whois.php.
It works in IE7, but not Firefox though. I've put the alerts in to help debug, and it does come up saying "Your browser is Opera, Firefox, or Safari". The output is then blank though.
whois.js:
Code:
//Browser Support Code
function showWhois(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
alert("Your browser is Opera, Firefox, or Safari");
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
alert("Your browser is IE1");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
alert("Your browser is IE2");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('whoisResult');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var idomain = document.getElementById('domainInput').value;
var queryString = "?domain=" + idomain + "&sid="+Math.random();
ajaxRequest.open("GET", "whois.php" + queryString, true);
ajaxRequest.send(null);
}
Thanks,
Shell