Xplain.Db.Configuration
- Xplain.Db.Configuration()
Xplain.Db.Configuration is a singleton class that provides methods to set the default parameter used within all ajax requests sent to the backend. Example usage:
Xplain.Db.Configuration.setDefaults({ // timeouts = 0 means there is no timeout... timeout: 0, // use asynchronous communication async: true, // set default error handler error: function() {alert('oops... something went wrong');} });
See the
setDefaults
method for a description of all default parameters.
getAllFinished
- getAllFinished(conf)
Returns the default
allFinished
function used.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.allFinished
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no function forallFinished
is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Function}
getAsync
- getAsync(conf)
Returns the default value for Async used for all requests.
- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.async
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no value for async is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Boolean}
getBefore
- getBefore(conf)
Returns the default
before
function used for all requests.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.before
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no function forbefore
is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Function}
getCors
- getCors(conf)
Returns the default value for CORS used for all requests.
- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.cors
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no value for CORS is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Boolean}
getCsrf
- getCsrf(conf)
Returns the default CSRF token used for all requests. This token will be generated and set by the backend. Therefore, you should not change this token.
- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.csrf
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no CSRF token is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{string}
getError
- getError(conf)
Returns the default
error
function used for all requests.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.error
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no function forerror
is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Function}
getForceJQuery
- getForceJQuery(conf)
Returns the default value for
forceJQuery
used for all requests, i.e. returnstrue
if jQuery will be used for all ajax requests andfalse
otherwise.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.forceJQuery
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no value forforceJQuery
is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Boolean}
getSuccess
- getSuccess(conf)
Returns the default
success
function used for all requests.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.success
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no function forsuccess
is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Function}
getThen
- getThen(conf)
Returns the default
then
function. This function gets executed when a request finishes (aftersuccess
anderror
functions are executed).- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.then
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no function forthen
is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Function}
getTimeout
- getTimeout(conf)
Returns the default timeout used for all requests.
- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.timeout
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no timeout is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{Integer}
getUrl
- getUrl(conf)
Returns the default URL used for all requests.
- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.Url
is set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()
will be returned. If no Url is specified usingXplain.Db.Configuration.setDefaults()
, the default value will be returned.- Returns
{string}
setDefaults
- setDefaults(defaults[, defaults.async=true][, defaults.cors=false][, defaults.url='/'][, defaults.timeout=15000][, defaults.before=f(){}][, defaults.success=f(data){}][, defaults.error=f(data){throw new Xplain.Db.Exception}][, defaults.then=f(data){}][, defaults.allFinished=f(data){}][, defaults.forceJQuery=false])
Use this method to set all defaults.
- Parameters
defaults (object) – A set of key/value pairs that configure all ajax requests. All settings are optional.
(optional) (boolean defaults.forceJQuery=false) – defines if the request sent to the backend should be asynchronous or synchronous.
(optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).
(optional) – The URL used for this request.
(optional) – number of milliseconds until a timeout will be triggered.
(optional) – function that will be triggered before the ajax request starts. If this function returns
false
, the Ajax request is being skipped (not executed).(optional) – function that will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be the resulting data.
(optional) – function that will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.
(optional) – function which will be triggered if this ajax request finishes (succeeded or failed).
(optional) – function which will be triggered if ALL ajax requests have finished (succeeded or failed).
(optional) – if set to
true
jQuery will be used for all ajax requests. This is useful, if you would like to enable the use of Internet Explorer.
- Returns
{Xplain.Db.Configurations}