Files
codeocean/app/assets/javascripts/editor/ajax.js
2021-11-23 01:37:50 +01:00

19 lines
482 B
JavaScript

CodeOceanEditorAJAX = {
ajax: function(options) {
return $.ajax(_.extend({
dataType: 'json',
method: 'POST',
}, options));
},
ajaxError: function(response) {
const responseJSON = ((response || {}).responseJSON || {});
const message = responseJSON.message || responseJSON.error || '';
$.flash.danger({
text: message.length > 0 ? message : $('#flash').data('message-failure'),
showPermanent: response.status === 422,
});
}
};