Some Ajax tip
1. XML data’s http mime type must be “text/xml”.
FF doesn’t recognize when mime type is set to “text/html”.
2. When parsing XML in FF, you must check dummy XML nodes,
ex) if (events[i].childNodes[j].nodeType != 1) continue;
3. There’s plenty of Ajax frameworks now a day.
e.g. Prototype, Dojo, DWR, etc.. and ruby on rails..
Consider frameworks for fast development..
4. Use date info for avoiding local cache problem
var now = new Date();
URL + now.getTime() ;
5. normal Ajax routine samples
if (window.ActiveXObject) { // IE
xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
xmlDoc.onreadystatechange= function () {
i f (xmlDoc.readyState == 4) getData();
};
}
else if (document.implementation && document.implementation.createDocument) { // FF
xmlDoc = document.implementation.createDocument(“”, “”, null);
xmlDoc.onload=getData;
}
else {
alert(‘Your browser cannot handle this script’);
return;
}
xmlDoc.load(URL);
6. Ajax is not always the best solution!
