I am new to AJAX. The script is working fine but what I want is when I click the "Enter" button
I want to show some sort of loading animation:
and hide it when the request comes through.
Markup:
<div id="loading" align="center" >
<img src="../dist/img/ajax-loader.gif" display="none" />
</div>
And also:
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function product() {
if(document.getElementById('privilege').value.length == 0) {
alert("Please choose privilege");
document.getElementById('privilege').focus();
return false;
}
var ajaxRequest; // The variable that makes Ajax possible!
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) {
var ajaxDisplay = document.getElementById('get');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var privilege = document.getElementById('privilege').value;
var queryString = "?privilege=" + privilege;
ajaxRequest.open("GET", "ajax_get.php" + queryString, true);
ajaxRequest.send(null);
//document.getElementById('Submit').disabled=false;
}
//-->
</script>