//////////////////////////////////////////////////////////////////////////////////// // Davidgos Basic AJAX Library //////////////////////////////////////////////////////////////////////////////////// // Find out how we can get the appropriate object (Microsoft or standards compliant ? function getHTTPObject() { if (typeof XMLHttpRequest != 'undefined') { return new XMLHttpRequest(); } try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } return false; } // Simply get the payload and send an alert (For testing) function alertfromserver(URL) { var http=getHTTPObject(); http.open("GET", URL ,true); http.onreadystatechange=function() { if (http.readyState==4) { alert(http.responseText) } } http.send(null) } // Simply get the payload and return // The CALLBACKFN is the function called (with the output from AJAX as text) // as its only parameter function getfromserver(URL,CALLBACKFN) { var http=getHTTPObject(); http.open("GET", URL ,true); http.onreadystatechange=function() { if (http.readyState==4) { CALLBACKFN(http.responseText); } } return http.send(null) } // Same as getfromserver except the callback function takes 2 params here, with the first being HTTP // response, and the second being param of interest function getfromserver2param(URL,CALLBACKFN,P2) { var http=getHTTPObject(); http.open("GET", URL ,true); http.onreadystatechange=function() { if (http.readyState==4) { CALLBACKFN(http.responseText,P2); } } return http.send(null) }