Callback function in javascript

function htmlData(url,ql, qStr)
{
var fieldname =”txtResult”+ql;
if (url.length==0)
{
document.getElementById(fieldname).innerHTML=””;
return;
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert (“Browser does not support HTTP Request”);
return;
}

url=url+”?”+qStr;
url=url+”&sid=”+Math.random();
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
document.getElementById(fieldname).innerHTML= xmlHttp.responseText;

}
}.bind(fieldname);

//stateChanged(‘000’);
xmlHttp.open(“GET”,url,true) ;
xmlHttp.send(null);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s