Venice Fitness. AJAX caching xml problems.

ajax synchronous vs. NON-synchronous

18 Oct 2006

So,

sometimes you dont want your call to be asyncchronous, when there is an order of operations to be followed, for example.

Here is a modification on the xml.com 'loadXmlDoc' method that takes asynch as a paramater, it also takes an xml bundle to post back to the server if you need to do that, leave it null if not.

// spacing gets mangled by wordpress

//XML utilities function loadXMLDoc(url,method,asynch,xmlPost) { _method = method; // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { XmlHttpreq = new XMLHttpRequest();

if (asynch == true){ XmlHttpreq.onreadystatechange = processReqChange; }

XmlHttpreq.open("POST", url, asynch); XmlHttpreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; Charset=utf-8"); XmlHttpreq.send(xmlPost);

if (asynch == false){ processReqChange() ; }

// branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { XmlHttpreq = new ActiveXObject("Microsoft.XMLHTTP"); if (XmlHttpreq) { if (asynch == true){ XmlHttpreq.onreadystatechange = processReqChange; }

XmlHttpreq.open("POST", url, asynch); XmlHttpreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; Charset=utf-8"); XmlHttpreq.send(xmlPost);

if (asynch == false){ processReqChange() ; } } } }