git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
81fda97
)
Rewrote $.xml a bit, cause the loading message got stuck (didn't hide) after fast...
author
Gilles van den Hoven
<gilles0181@gmail.com>
Sat, 20 May 2006 09:46:41 +0000
(09:46 +0000)
committer
Gilles van den Hoven
<gilles0181@gmail.com>
Sat, 20 May 2006 09:46:41 +0000
(09:46 +0000)
ajax/ajax.js
patch
|
blob
|
history
diff --git
a/ajax/ajax.js
b/ajax/ajax.js
index
ef7240f
..
fef1e22
100644
(file)
--- a/
ajax/ajax.js
+++ b/
ajax/ajax.js
@@
-9,7
+9,6
@@
if ( typeof XMLHttpRequest == 'undefined' && typeof window.ActiveXObject == 'fun
};
}
};
}
-//
// Counter for holding the active query's
$.xmlActive=0;
// Counter for holding the active query's
$.xmlActive=0;
@@
-17,25
+16,11
@@
$.xml = function( type, url, data, ret ) {
var xml = new XMLHttpRequest();
if ( xml ) {
var xml = new XMLHttpRequest();
if ( xml ) {
- //
- // Increase the query counter
- $.xmlActive++;
-
- //
- // Show loader if needed
- if ($.xmlCreate) {
- $.xmlCreate();
- }
-
- //
// Open the socket
xml.open(type || "GET", url, true);
// Open the socket
xml.open(type || "GET", url, true);
-
- if ( data ) {
+ if ( data )
xml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- }
- //
// Set header so calling script knows that it's an XMLHttpRequest
xml.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
// Set header so calling script knows that it's an XMLHttpRequest
xml.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
@@
-43,29
+28,38
@@
$.xml = function( type, url, data, ret ) {
* a bug where XMLHttpReqeuest sends an incorrect Content-length
* header. See Mozilla Bugzilla #246651.
*/
* a bug where XMLHttpReqeuest sends an incorrect Content-length
* header. See Mozilla Bugzilla #246651.
*/
- if ( xml.overrideMimeType ) {
+ if ( xml.overrideMimeType )
xml.setRequestHeader('Connection', 'close');
xml.setRequestHeader('Connection', 'close');
- }
xml.onreadystatechange = function() {
xml.onreadystatechange = function() {
- if ( xml.readyState == 4 ) {
- if ( ret ) { ret(xml); }
+ // Socket is openend
+ if ( xml.readyState == 1 ) {
+ // Increase counter
+ $.xmlActive++;
+
+ // Show loader if needed
+ if ( ($.xmlActive >= 1) && ($.xmlCreate) )
+ $.xmlCreate();
+ }
- //
+ // Socket is closed and data is available
+ if ( xml.readyState == 4 ) {
// Decrease counter
$.xmlActive--;
// Decrease counter
$.xmlActive--;
- //
// Hide loader if needed
// Hide loader if needed
- if ($.xmlActive <= 0) {
- if ($.xmlDestroy) {
- $.xmlDestroy();
- }
+ if ( ($.xmlActive <= 0) && ($.xmlDestroy) ) {
+ $.xmlDestroy();
+ $.xmlActive = 0
}
}
+
+ // Process result
+ if ( ret )
+ ret(xml);
}
};
}
};
- xml.send(data);
+ xml.send(data)
}
};
}
};