mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 10:06:53 +08:00
27 lines
522 B
JavaScript
27 lines
522 B
JavaScript
/*
|
|
* Converts JSON data received from the server to flat array of values.
|
|
*/
|
|
function jsonToValuesArray(jsonData) {
|
|
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();
|
|
});
|
|
}
|