mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 21:24:54 +08:00
27 lines
534 B
JavaScript
27 lines
534 B
JavaScript
/*
|
|
* Converts JSON data received from the server to flat array of values.
|
|
*/
|
|
function jsonToValuesArray(jsonData) {
|
|
var errMsgs = [];
|
|
for (var key in jsonData) {
|
|
var values = jsonData[key];
|
|
$.each(values, function (idx, val) {
|
|
errMsgs.push(val);
|
|
});
|
|
}
|
|
return errMsgs;
|
|
}
|
|
|
|
/*
|
|
* Calls callback function on AJAX success (because built-in functions don't
|
|
* work!)
|
|
*/
|
|
$.fn.onAjaxComplete = function (cb) {
|
|
$(this)
|
|
.on('ajax:success', function () {
|
|
cb();
|
|
})
|
|
.on('ajax:error', function () {
|
|
cb();
|
|
});
|
|
}
|