summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-08-20 06:22:35 +0000
committerDries Buytaert <dries@buytaert.net>2006-08-20 06:22:35 +0000
commit3646f8914f3c58a4c5178cf5db484cef246918fb (patch)
tree2088f8373f64b0823420868a668947e6bedd42ad /misc
parent55eec8f66f909fd105074142d99e22e02b489991 (diff)
downloadbrdo-3646f8914f3c58a4c5178cf5db484cef246918fb.tar.gz
brdo-3646f8914f3c58a4c5178cf5db484cef246918fb.tar.bz2
- Patch #49993 by Sid_M: fixed two minor problems with HTTPGet().
1) There is a race condition created by calling send() before setting the callback function. Admittedly, this race shouldn't be lost, but it's not good practice to bet on winning races in code. 2) Line 55 is redundant. Since the value of bAsync is based on the non/existence of callbackFunction, there is no need to check both variables later.
Diffstat (limited to 'misc')
-rw-r--r--misc/drupal.js17
1 files changed, 7 insertions, 10 deletions
diff --git a/misc/drupal.js b/misc/drupal.js
index 539338ea3..4fd536463 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -48,15 +48,14 @@ function HTTPGet(uri, callbackFunction, callbackParameter) {
if (!callbackFunction) {
bAsync = false;
}
+
xmlHttp.open('GET', uri, bAsync);
xmlHttp.send(null);
if (bAsync) {
- if (callbackFunction) {
- xmlHttp.onreadystatechange = function() {
- if (xmlHttp.readyState == 4) {
- callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
- }
+ xmlHttp.onreadystatechange = function() {
+ if (xmlHttp.readyState == 4) {
+ callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
}
}
return xmlHttp;
@@ -93,11 +92,9 @@ function HTTPPost(uri, callbackFunction, callbackParameter, object) {
xmlHttp.send(toSend);
if (bAsync) {
- if (callbackFunction) {
- xmlHttp.onreadystatechange = function() {
- if (xmlHttp.readyState == 4) {
- callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
- }
+ xmlHttp.onreadystatechange = function() {
+ if (xmlHttp.readyState == 4) {
+ callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
}
}
return xmlHttp;