show dialog when ajax requests fail

This commit is contained in:
Min RK
2015-01-29 14:59:11 -08:00
parent e12dde371f
commit 056cd0c246
4 changed files with 25 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ define(['jquery', 'utils'], function ($, utils) {
dataType : "json",
processData: false,
success: null,
error: utils.log_jax_error,
error: utils.ajax_error_dialog,
};
var update = function (d1, d2) {

View File

@@ -108,6 +108,15 @@ define(['jquery'], function($){
console.log(jqXHR);
msg += ajax_error_msg(jqXHR);
console.log(msg);
return msg;
};
var ajax_error_dialog = function (jqXHR, status, error) {
console.log("ajax dialog", arguments);
var msg = log_ajax_error(jqXHR, status, error);
var dialog = $("#error-dialog");
dialog.find(".ajax-error").text(msg);
dialog.modal();
};
var utils = {
@@ -121,6 +130,7 @@ define(['jquery'], function($){
platform: platform,
ajax_error_msg : ajax_error_msg,
log_ajax_error : log_ajax_error,
ajax_error_dialog : ajax_error_dialog,
};
return utils;

View File

@@ -3,6 +3,12 @@ div.error {
text-align: center;
}
div.ajax-error {
padding: 1em;
text-align: center;
.alert-danger();
}
div.error > h1 {
font-size: 500%;
line-height: normal;

View File

@@ -19,6 +19,8 @@
</div>
</div>
{% endmacro %}
<!DOCTYPE HTML>
<html>
@@ -102,6 +104,12 @@
{% block main %}
{% endblock %}
{% call modal('Error', btn_label='OK') %}
<div class="ajax-error">
The error
</div>
{% endcall %}
{% block script %}
{% endblock %}