Beginners Ajax Tutorial

July 12th, 2012 | No Comments | Posted in Php & MySql, Programming


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;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.myForm.time.value = ajaxRequest.responseText;
}
}
ajaxRequest.open(“GET”, “result.php”, true);
ajaxRequest.send(null);
}

//–>

 


Name:

Time:


result.php file:

echo “Welcome to Ajax”;
?>

Leave a Reply 107 views, 1 so far today |

Most Commented Posts

Leave a Reply

CAPTCHA Image
Refresh Image
*