--- a/includes/clientside/static/ajax.js Wed Jun 18 22:43:16 2008 -0400
+++ b/includes/clientside/static/ajax.js Sun Jun 22 18:13:59 2008 -0400
@@ -2,6 +2,22 @@
* AJAX applets
*/
+function ajaxMakeXHR()
+{
+ var ajax;
+ if (window.XMLHttpRequest) {
+ ajax = new XMLHttpRequest();
+ } else {
+ if (window.ActiveXObject) {
+ ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ } else {
+ alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ return;
+ }
+ }
+ return ajax;
+}
+
function ajaxGet(uri, f, call_editor_safe) {
// Is the editor open?
if ( editor_open && !call_editor_safe )
@@ -18,15 +34,11 @@
editor_open = false;
enableUnload();
}
- if (window.XMLHttpRequest) {
- ajax = new XMLHttpRequest();
- } else {
- if (window.ActiveXObject) {
- ajax = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- alert('Enano client-side runtime error: No AJAX support, unable to continue');
- return;
- }
+ ajax = ajaxMakeXHR();
+ if ( !ajax )
+ {
+ console.error('ajaxMakeXHR() failed');
+ return false;
}
ajax.onreadystatechange = f;
ajax.open('GET', uri, true);
@@ -50,15 +62,11 @@
editor_open = false;
enableUnload();
}
- if (window.XMLHttpRequest) {
- ajax = new XMLHttpRequest();
- } else {
- if (window.ActiveXObject) {
- ajax = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- alert('Enano client-side runtime error: No AJAX support, unable to continue');
- return;
- }
+ ajax = ajaxMakeXHR();
+ if ( !ajax )
+ {
+ console.error('ajaxMakeXHR() failed');
+ return false;
}
ajax.onreadystatechange = f;
ajax.open('POST', uri, true);