Loading

Thursday, April 23, 2009

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;
}

SHARE TWEET

Thank you for reading this article Ajax lookup function With URL https://x-tutorials.blogspot.com/2009/04/ajax-lookup-function.html. Also a time to read the other articles.

0 comments:

Write your comment for this article Ajax lookup function above!