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
setDefaultsmethod for a description of all default parameters.
getAllFinished
- getAllFinished(conf)
Returns the default
allFinishedfunction used.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.allFinishedis set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()will be returned. If no function forallFinishedis 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.asyncis 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
beforefunction used for all requests.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.beforeis set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()will be returned. If no function forbeforeis 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.corsis 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.csrfis 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
errorfunction used for all requests.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.erroris set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()will be returned. If no function forerroris specified usingXplain.Db.Configuration.setDefaults(), the default value will be returned.- Returns
{Function}
getForceJQuery
- getForceJQuery(conf)
Returns the default value for
forceJQueryused for all requests, i.e. returnstrueif jQuery will be used for all ajax requests andfalseotherwise.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.forceJQueryis set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()will be returned. If no value forforceJQueryis specified usingXplain.Db.Configuration.setDefaults(), the default value will be returned.- Returns
{Boolean}
getSuccess
- getSuccess(conf)
Returns the default
successfunction used for all requests.- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.successis set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()will be returned. If no function forsuccessis specified usingXplain.Db.Configuration.setDefaults(), the default value will be returned.- Returns
{Function}
getThen
- getThen(conf)
Returns the default
thenfunction. This function gets executed when a request finishes (aftersuccessanderrorfunctions are executed).- Parameters
conf (object) – A set of key/values pairs that configure an ajax request. If parameter
conf.thenis set, this value will be returned. If not, the default set usingXplain.Db.Configuration.setDefaults()will be returned. If no function forthenis 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.timeoutis 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.Urlis 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
truejQuery 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}