$.xmlActive=0;
$.xml = function( type, url, data, ret ) {
+ if ( !url ) {
+ ret = type.onComplete;
+ var onSuccess = type.onSuccess;
+ var onError = type.onError;
+ data = type.data;
+ url = type.url;
+ type = type.type;
+ }
+
var xml = new XMLHttpRequest();
if ( xml ) {
// Set header so calling script knows that it's an XMLHttpRequest
xml.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
- /* Force "Connection: close" for Mozilla browsers to work around
+ /* Borrowed from Prototype:
+ * Force "Connection: close" for Mozilla browsers to work around
* a bug where XMLHttpReqeuest sends an incorrect Content-length
* header. See Mozilla Bugzilla #246651.
*/
$.xmlActive = 0
}
+ if ( xml.status && xml.status >= 200 && xml.status < 300 ) {
+ if ( onSuccess )
+ onSuccess( xml );
+ } else if ( onError ) {
+ onError( xml );
+ }
+
// Process result
if ( ret )
ret(xml);
t = "POST";
}
var self = this;
- $.xml(t,a,o,function(h){
- // Get HTTP data
- h = $.httpData(h);
-
+ $.xml(t,a,o,function(res){
// Assign it and execute all scripts
- self.html(h).find("script").each(function(){
- try { $.execute( this.text || this.textContent || this.innerHTML || ""); } catch(e){}
+ self.html(res.responseText).find("script").each(function(){
+ try { eval( this.text || this.textContent || this.innerHTML || ""); } catch(e){}
});
// Callback function
if (f && f.constructor == Function)
- f(h);
+ f(res.responseText);
});
return this;
};
$(target).load(url, this.vars, post_cb);
} else {
this.vars.push({name: 'evaljs', value: 1});
- $.xml(mth, url, $.param(this.vars), function(r) { $.execute(r.responseText); });
+ $.xml(mth, url, $.param(this.vars), function(r) { eval(r.responseText); });
}
return this;
}
-
-// ------------------------------------------------------
-
-$.fn.changer = function(form, target, pre_cb, post_cb) {
- $(form).submit(function(e) {
- e.preventDefault();
- return false;
- });
- this.change(function(e) {
- e.preventDefault();
- $(form).getForm().putForm(target, pre_cb, post_cb);
- return this;
- });
-}
\ No newline at end of file