fix error when no error handling function was defined

This commit is contained in:
Stefan Breunig
2013-02-02 00:35:37 +01:00
parent 0a2890f196
commit 1c7a6ab70d

View File

@ -48,16 +48,14 @@ window.digits = function(d) {
// error: see above. Additionally it is logged if the request failed. // error: see above. Additionally it is logged if the request failed.
window.postAjax = function(action, data, success, error) { window.postAjax = function(action, data, success, error) {
data = JSON.stringify($.extend({method: 'dashboard.'+action}, data)); data = JSON.stringify($.extend({method: 'dashboard.'+action}, data));
var errCnt = function(jqXHR) { window.failedRequestCount++; window.requests.remove(jqXHR); };
return $.ajax({ return $.ajax({
url: 'rpc/dashboard.'+action, url: 'rpc/dashboard.'+action,
type: 'POST', type: 'POST',
data: data, data: data,
dataType: 'json', dataType: 'json',
success: success, success: success,
error: [ error: error ? [errCnt, error] : errCnt,
function(jqXHR) { window.failedRequestCount++; window.requests.remove(jqXHR); },
error || null
],
contentType: 'application/json; charset=utf-8', contentType: 'application/json; charset=utf-8',
beforeSend: function(req) { beforeSend: function(req) {
req.setRequestHeader('X-CSRFToken', readCookie('csrftoken')); req.setRequestHeader('X-CSRFToken', readCookie('csrftoken'));