Ajax lookup function

Here is a simple look up function using ajax (XMLHttpRequest object).

function lookup(tbl,res,fld,val) {
var req;
var url='lookup.php?tbl='+tbl+'&res='+res+'&fld='+fld+'&val='+val;
req = false;
// branch for native XMLHttpRequest object

if(window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
if(req) {
//req.onreadystatechange = processReqChange;
req.open("GET", url, false);
req.send('-');
}
return req.responseText;
}

Useful Links on Adobe Flex

Your Ad Here

Latest Books on Adobe Flex