How to add loader img with this code?

Hi All,

Im using below code to load the page when im selecting option in dropdownbox. Now, I need to add loader img before load page…

Plz someon

var xmlhttp;

function showUser(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="sort_order_by.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("right_big").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

e help.Thanks in advance

If this were true, the browser just wouldn’t be able to access the internet:

Browser does not support HTTP Request

You mean XMLHttpRequests.

Where is this loading image going to go? All you have to do is add the image wherever you want it the moment the XMLHttpRequest is initiated, and when xmlhttpreadyState==4, then you remove it.

thanks for reply…
Loader image is images/loader.gif. I have to call it before th page loads . im not well in js. If you know please reply.

Is this possible to add this var?

var loadingtxt = '<img src="images/loading.gif"> Loading please wait...'; /*