- ajax: function( type, url, data, ret, ifModified ) {
- // If only a single argument was passed in,
- // assume that it is a object of key/value pairs
- var global = true;
- var timeout = jQuery.timeout;
- if ( !url ) {
- ret = type.complete;
- var success = type.success;
- var error = type.error;
- var dataType = type.dataType;
- var global = typeof type.global == "boolean" ? type.global : true;
- var timeout = typeof type.timeout == "number" ? type.timeout : jQuery.timeout;
- var ifModified = type.ifModified || false;
- data = type.data;
- url = type.url;
- type = type.type;
+ ajax: function( s ) {
+ // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
+ s = jQuery.extend({
+ global: true,
+ ifModified: false,
+ type: "GET",
+ timeout: jQuery.timeout,
+ complete: null,
+ success: null,
+ error: null,
+ dataType: null,
+ data: null,
+ url: null
+ }, s);
+
+ // if data available
+ if ( s.data ) {
+ // convert data if not already a string
+ if (typeof s.data != 'string')
+ s.data = jQuery.param(s.data);
+ // append data to url for get requests
+ if( s.type.toLowerCase() == "get" )
+ // "?" + data or "&" + data (in case there are already params)
+ s.url += ((s.url.indexOf("?") > -1) ? "&" : "?") + s.data;