Check error code when no completion function is defined as well
authorJoey Schulze <joey@infodrom.org>
Sat, 27 Feb 2010 16:08:17 +0000 (17:08 +0100)
committerJoey Schulze <joey@infodrom.org>
Sat, 27 Feb 2010 16:08:17 +0000 (17:08 +0100)
lib/functions.js

index 8554e2b..e4c6e50 100644 (file)
@@ -24,10 +24,9 @@ function ajax_request(func,params,oncomplete)
     req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     req.setRequestHeader("Content-length", params.length);
     req.setRequestHeader("Connection", "close");
-    if (typeof oncomplete == 'function') {
-       req.onreadystatechange = function() { ajax_request_callback(req); }
+    req.onreadystatechange = function() { ajax_request_callback(req); }
+    if (typeof oncomplete == 'function')
        req.oncomplete = oncomplete;
-    }
     req.send(params);
 }