* can be attached to the promises returned by this function.
* @param {Boolean} async Optional, defaults to true.
* If false - this function will not return until the promises are resolved.
+ * @param {Boolean} loginrequired Optional, defaults to true.
+ * If false - this function will call the faster nologin ajax script - but
+ * will fail unless all functions have been marked as 'loginrequired' => false
+ * in services.php
* @return {Promise[]} Array of promises that will be resolved when the ajax call returns.
*/
- call: function(requests, async) {
+ call: function(requests, async, loginrequired) {
var ajaxRequestData = [],
i,
promises = [];
async: async
};
+ var script = config.wwwroot + '/lib/ajax/service.php?sesskey=' + config.sesskey;
+ if (!loginrequired) {
+ script = config.wwwroot + '/lib/ajax/service-nologin.php?sesskey=' + config.sesskey;
+ }
+
// Jquery deprecated done and fail with async=false so we need to do this 2 ways.
if (async) {
- $.ajax(config.wwwroot + '/lib/ajax/service.php?sesskey=' + config.sesskey, settings)
+ $.ajax(script, settings)
.done(requestSuccess)
.fail(requestFail);
} else {
settings.success = requestSuccess;
settings.error = requestFail;
- $.ajax(config.wwwroot + '/lib/ajax/service.php?sesskey=' + config.sesskey, settings);
+ $.ajax(script, settings);
}
return promises;