2006-03-22 03:33:07 +00:00
|
|
|
// AJAX Plugin
|
|
|
|
// Docs Here:
|
|
|
|
// http://jquery.com/docs/ajax/
|
|
|
|
|
|
|
|
if ( typeof XMLHttpRequest == 'undefined' && typeof window.ActiveXObject == 'function') {
|
2006-05-16 22:15:05 +00:00
|
|
|
XMLHttpRequest = function() {
|
2006-05-16 16:18:52 +00:00
|
|
|
return new ActiveXObject((navigator.userAgent.toLowerCase().indexOf('msie 5') >= 0) ?
|
2006-03-23 21:13:20 +00:00
|
|
|
"Microsoft.XMLHTTP" : "Msxml2.XMLHTTP");
|
|
|
|
};
|
2006-03-22 03:33:07 +00:00
|
|
|
}
|
|
|
|
|
2006-05-16 16:18:52 +00:00
|
|
|
// Counter for holding the active query's
|
|
|
|
$.xmlActive=0;
|
|
|
|
|
2006-03-22 03:33:07 +00:00
|
|
|
$.xml = function( type, url, data, ret ) {
|
2006-03-23 21:13:20 +00:00
|
|
|
var xml = new XMLHttpRequest();
|
2006-03-22 03:33:07 +00:00
|
|
|
|
2006-03-23 21:13:20 +00:00
|
|
|
if ( xml ) {
|
2006-05-16 16:18:52 +00:00
|
|
|
// Open the socket
|
2006-03-23 21:13:20 +00:00
|
|
|
xml.open(type || "GET", url, true);
|
2006-05-20 09:46:41 +00:00
|
|
|
if ( data )
|
2006-03-23 21:13:20 +00:00
|
|
|
xml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
2006-03-22 03:33:07 +00:00
|
|
|
|
2006-05-16 16:18:52 +00:00
|
|
|
// 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
|
|
|
|
* a bug where XMLHttpReqeuest sends an incorrect Content-length
|
|
|
|
* header. See Mozilla Bugzilla #246651.
|
|
|
|
*/
|
2006-05-20 09:46:41 +00:00
|
|
|
if ( xml.overrideMimeType )
|
2006-05-16 16:18:52 +00:00
|
|
|
xml.setRequestHeader('Connection', 'close');
|
|
|
|
|
2006-03-27 07:08:32 +00:00
|
|
|
xml.onreadystatechange = function() {
|
2006-05-20 09:46:41 +00:00
|
|
|
// Socket is openend
|
|
|
|
if ( xml.readyState == 1 ) {
|
|
|
|
// Increase counter
|
|
|
|
$.xmlActive++;
|
|
|
|
|
|
|
|
// Show loader if needed
|
|
|
|
if ( ($.xmlActive >= 1) && ($.xmlCreate) )
|
|
|
|
$.xmlCreate();
|
|
|
|
}
|
2006-05-16 16:18:52 +00:00
|
|
|
|
2006-05-20 09:46:41 +00:00
|
|
|
// Socket is closed and data is available
|
|
|
|
if ( xml.readyState == 4 ) {
|
2006-05-16 16:18:52 +00:00
|
|
|
// Decrease counter
|
|
|
|
$.xmlActive--;
|
|
|
|
|
|
|
|
// Hide loader if needed
|
2006-05-20 09:46:41 +00:00
|
|
|
if ( ($.xmlActive <= 0) && ($.xmlDestroy) ) {
|
|
|
|
$.xmlDestroy();
|
|
|
|
$.xmlActive = 0
|
2006-05-16 16:18:52 +00:00
|
|
|
}
|
2006-05-20 09:46:41 +00:00
|
|
|
|
|
|
|
// Process result
|
|
|
|
if ( ret )
|
|
|
|
ret(xml);
|
2006-03-27 07:08:32 +00:00
|
|
|
}
|
|
|
|
};
|
2006-03-22 03:33:07 +00:00
|
|
|
|
2006-05-20 09:46:41 +00:00
|
|
|
xml.send(data)
|
2006-03-23 21:13:20 +00:00
|
|
|
}
|
2006-03-22 03:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.httpData = function(r,type) {
|
2006-03-23 21:13:20 +00:00
|
|
|
return r.getResponseHeader("content-type").indexOf("xml") > 0 || type == "xml" ?
|
|
|
|
r.responseXML : r.responseText;
|
2006-03-22 03:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.get = function( url, ret, type ) {
|
2006-03-23 21:13:20 +00:00
|
|
|
$.xml( "GET", url, null, function(r) {
|
2006-05-16 22:15:05 +00:00
|
|
|
if ( ret ) { ret( $.httpData(r,type) ); }
|
2006-03-23 21:13:20 +00:00
|
|
|
});
|
2006-03-22 03:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.getXML = function( url, ret ) {
|
2006-03-23 21:13:20 +00:00
|
|
|
$.get( url, ret, "xml" );
|
2006-03-22 03:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.post = function( url, data, ret, type ) {
|
2006-03-23 21:13:20 +00:00
|
|
|
$.xml( "POST", url, $.param(data), function(r) {
|
2006-05-16 22:15:05 +00:00
|
|
|
if ( ret ) { ret( $.httpData(r,type) ); }
|
2006-03-23 21:13:20 +00:00
|
|
|
});
|
2006-03-22 03:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.postXML = function( url, data, ret ) {
|
2006-03-23 21:13:20 +00:00
|
|
|
$.post( url, data, ret, "xml" );
|
2006-03-22 03:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.param = function(a) {
|
2006-03-23 21:13:20 +00:00
|
|
|
var s = [];
|
2006-05-16 16:18:52 +00:00
|
|
|
if (a && typeof a == 'object' && a.constructor == Array) {
|
2006-05-16 22:15:05 +00:00
|
|
|
for ( var i=0; i < a.length; i++ ) {
|
|
|
|
s[s.length] = a[i].name + "=" + encodeURIComponent( a[i].value );
|
|
|
|
}
|
2006-05-16 16:18:52 +00:00
|
|
|
} else {
|
2006-05-16 22:15:05 +00:00
|
|
|
for ( var j in a ) {
|
|
|
|
s[s.length] = j + "=" + encodeURIComponent( a[j] );
|
|
|
|
}
|
2006-05-16 16:18:52 +00:00
|
|
|
}
|
2006-03-23 21:13:20 +00:00
|
|
|
return s.join("&");
|
2006-03-22 03:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.fn.load = function(a,o,f) {
|
2006-03-23 21:13:20 +00:00
|
|
|
// Arrrrghhhhhhhh!!
|
|
|
|
// I overwrote the event plugin's .load
|
|
|
|
// this won't happen again, I hope -John
|
2006-05-16 22:15:05 +00:00
|
|
|
if ( a && a.constructor == Function ) {
|
2006-03-23 21:13:20 +00:00
|
|
|
return this.bind("load", a);
|
2006-05-16 22:15:05 +00:00
|
|
|
}
|
2006-03-22 03:33:07 +00:00
|
|
|
|
2006-03-23 21:13:20 +00:00
|
|
|
var t = "GET";
|
|
|
|
if ( o && o.constructor == Function ) {
|
|
|
|
f = o;
|
|
|
|
o = null;
|
|
|
|
}
|
2006-05-16 22:15:05 +00:00
|
|
|
if (o !== null) {
|
2006-03-23 21:13:20 +00:00
|
|
|
o = $.param(o);
|
|
|
|
t = "POST";
|
|
|
|
}
|
|
|
|
var self = this;
|
|
|
|
$.xml(t,a,o,function(h){
|
2006-05-16 22:15:05 +00:00
|
|
|
h = h.responseText;
|
2006-03-23 21:13:20 +00:00
|
|
|
self.html(h).find("script").each(function(){
|
|
|
|
try {
|
2006-05-17 02:42:03 +00:00
|
|
|
$.eval( this.text || this.textContent || this.innerHTML );
|
2006-03-23 21:13:20 +00:00
|
|
|
} catch(e){}
|
|
|
|
});
|
2006-05-16 22:15:05 +00:00
|
|
|
if(f){f(h);}
|
2006-03-23 21:13:20 +00:00
|
|
|
});
|
|
|
|
return this;
|
2006-03-22 03:33:07 +00:00
|
|
|
};
|
2006-05-16 16:18:52 +00:00
|
|
|
|
|
|
|
/**
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
* name: $.fn.formValues
|
|
|
|
* example: $('#frmLogin').formValues('sButton')
|
|
|
|
* docs: Gets form values and creates a key=>value array of the found values.
|
|
|
|
* Optionally adds the button which is clicked if you provide it.
|
|
|
|
* Only does this for ENABLED elements in the order of the form.
|
2006-05-16 16:18:52 +00:00
|
|
|
*/
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
$.fn.formValues = function(sButton) {
|
2006-05-16 22:15:05 +00:00
|
|
|
var a = [];
|
2006-06-02 14:27:25 +00:00
|
|
|
var ok = {INPUT:true, TEXTAREA:true, OPTION:true};
|
2006-05-17 18:04:46 +00:00
|
|
|
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
// Loop the shite
|
|
|
|
$('*', this).each(function() {
|
2006-06-02 14:27:25 +00:00
|
|
|
// Skip elements not of the types in ok
|
|
|
|
if (!ok[this.tagName.toUpperCase()])
|
2006-06-01 16:40:37 +00:00
|
|
|
return;
|
|
|
|
|
2006-06-02 14:27:25 +00:00
|
|
|
// Skip disabled elements
|
|
|
|
if (this.disabled)
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
return;
|
|
|
|
|
2006-06-01 16:40:37 +00:00
|
|
|
// Skip submit buttons and image elements
|
|
|
|
if ((this.type == 'submit') || (this.type == 'image'))
|
2006-05-31 16:29:43 +00:00
|
|
|
return;
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
|
2006-06-01 16:40:37 +00:00
|
|
|
// Skip non-selected options
|
2006-06-02 14:27:25 +00:00
|
|
|
var oParent = this.parentNode;
|
|
|
|
var sNn = oParent.nodeName.toUpperCase();
|
|
|
|
if (((sNn == 'SELECT') || (sNn == 'OPTGROUP')) && (!this.selected))
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Skip non-checked nodes
|
|
|
|
if (((this.type == 'radio') || (this.type == 'checkbox')) && (!this.checked))
|
|
|
|
return;
|
2006-05-17 18:04:46 +00:00
|
|
|
|
2006-06-01 16:40:37 +00:00
|
|
|
// If we come here, everything is fine
|
2006-06-02 14:27:25 +00:00
|
|
|
var sKey = this.name || this.id || oParent.name || oParent.id;
|
|
|
|
var sValue = this.value;
|
|
|
|
|
|
|
|
// If we don't have an ID, and the parent is an OPTGROUP,
|
|
|
|
// get the NAME or ID of the OPTGROUP's parent
|
|
|
|
if ((!sKey) && (sNn == 'OPTGROUP') && (oParent = oParent.parentNode))
|
|
|
|
sKey = oParent.name || oParent.id;
|
2006-06-01 16:40:37 +00:00
|
|
|
|
|
|
|
// Add the data
|
2006-06-02 14:27:25 +00:00
|
|
|
a.push({ name: sKey, value: sValue });
|
2006-05-17 18:04:46 +00:00
|
|
|
});
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
|
|
|
|
// Add submit button if needed
|
2006-05-31 16:29:43 +00:00
|
|
|
if (sButton && (sButton !== null)) {
|
|
|
|
var el = $(sButton).get(0);
|
|
|
|
a.push({
|
|
|
|
name: el.name || el.id || el.parentNode.name || el.parentNode.id,
|
|
|
|
value: el.value
|
|
|
|
});
|
|
|
|
}
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
|
2006-05-31 16:29:43 +00:00
|
|
|
// Done
|
2006-05-16 16:18:52 +00:00
|
|
|
return a;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
* name: $.fn.update
|
|
|
|
* example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
|
|
|
|
* docs: Calls sURL with sAction and sends the aValues
|
|
|
|
* Puts the results from that call in the jQuery object and calls fCallback
|
2006-05-16 16:18:52 +00:00
|
|
|
*/
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
$.fn.update = function(sURL, sMethod, aValues, fCallback) {
|
|
|
|
var el = this;
|
|
|
|
|
|
|
|
// Process
|
|
|
|
$.xml(
|
|
|
|
sMethod || "GET",
|
|
|
|
sURL || "",
|
|
|
|
$.param(aValues),
|
|
|
|
function(sResult) {
|
|
|
|
sResult = $.httpData(sResult);
|
|
|
|
|
|
|
|
// Update the element with the new HTML
|
|
|
|
el.html(sResult);
|
|
|
|
|
|
|
|
// Evaluate the scripts AFTER this (so you can allready modify the new HTML!)
|
|
|
|
el.html(sResult).find("script").each(function(){
|
|
|
|
try { $.eval( this.text || this.textContent || this.innerHTML ); } catch(e) { }
|
|
|
|
});
|
|
|
|
|
|
|
|
// And call the callback handler :)
|
|
|
|
if (fCallback && (fCallback.constructor == Function))
|
|
|
|
fCallback();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2006-05-16 16:18:52 +00:00
|
|
|
|
$.fn.formValues;
Gets form values and creates a key=>value array of the found values.
What's new?
- Only does this for ENABLED elements.
- Keeps the same order of the form.
- Optionally adds the button which is clicked (marks that name with an 'x' in the list)
example: $('#frmLogin').formValues('oButton');
$.fn.update (PREVIOUSLY: $.update, so beware!!!!)
Calls sURL with sAction (method) and sends the aValues. Puts the results from that call in the jQuery object and calls fCallback if provided.
What's new?
- Renamed $.update to $.fn.update, since it is more obvious to call $('someJQueryObject').update(...) then $.update($('someJQueryObject'), ...). It's also more jQuery-ish
- Added the method you want to use, since i used post before, now you can select between either GET or POST.
example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
$.fn.serialize
Calls the form's action with the correct method and the serialized values. Optionally adds the button which is clicked if you provide it. When there are results, the fCallback function is called.
What's new?
- The entire function
example: $('someForm').serialize('sButton', 'fCallback');
2006-05-31 11:14:21 +00:00
|
|
|
/**
|
|
|
|
* name: $.fn.serialize
|
|
|
|
* example: $('someJQueryObject').serialize('sButton', 'fCallback');
|
|
|
|
* docs: Calls the form's action with the correct method and the serialized values.
|
|
|
|
* Optionally adds the button which is clicked if you provide it.
|
|
|
|
* When there are results, the fCallback function is called.
|
|
|
|
*/
|
|
|
|
$.fn.serialize = function(sButton, fCallback) {
|
|
|
|
var el = this.get(0);
|
|
|
|
|
|
|
|
// Process
|
|
|
|
$.xml(
|
|
|
|
el.method || "GET",
|
|
|
|
el.action || "",
|
|
|
|
$.param(this.formValues(sButton)),
|
|
|
|
function(sResult) {
|
|
|
|
if (fCallback && (fCallback.constructor == Function))
|
|
|
|
fCallback($.httpData(sResult));
|
|
|
|
}
|
|
|
|
);
|
2006-05-16 16:18:52 +00:00
|
|
|
};
|