// stores the reference to the XMLHttpRequest object var xmlHttp = createXmlHttpRequestObject(); // retrieves the XMLHttpRequest object function createXmlHttpRequestObject() { var xmlHttp; if(window.ActiveXObject) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlHttp = false; } } // if running Mozilla or other browsers else { try { xmlHttp = new XMLHttpRequest(); } catch (e) { xmlHttp = false; } } if (!xmlHttp) alert("Error creating the XMLHttpRequest object."); else return xmlHttp; } // make asynchronous HTTP request using the XMLHttpRequest object function process(productid,divid) { ObjDiv = document.getElementById("divMessage"+divid); ObjDiv.innerHTML ="Loading....."; xmlHttp.open("GET","ImagesA.php?ProductID="+productid, true); xmlHttp.onreadystatechange = handleServerResponse; xmlHttp.send(null); } function handleServerResponse() { if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { ObjDiv.innerHTML = xmlHttp.responseText; } else { alert("There was a problem accessing the server: " + xmlHttp.statusText); } } }
|