Commit 93c8f527 authored by Łukasz Nowak's avatar Łukasz Nowak

Basic ajax error handling.

Provide a placeholder for ajax errors and just ask user to reload page when
such error happens.

During each ajax communication starts cleanup the handler, in order to have it
empty in case if next request was successful.
parent 32c46b3f
......@@ -49,7 +49,11 @@
<div id="js_container"></div>\n
<script type="text/javascript">\n
$(document).ready(function() {\n
$.ajaxSetup ({cache: false});\n
$(document).ajaxStart(cleanAjaxError);\n
$.ajaxSetup ({\n
cache: false,\n
error: processAjaxError\n
});\n
$.getJSON(vifib[\'site_url\'] + "/ERP5Site_getSoftwareCategoryTreeAsJSON", drawSoftwareCategoryTree);\n
$(window).hashchange(hashController);\n
$(window).hashchange();\n
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts23190925.51</string> </value>
<value> <string>ts23256173.14</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -484,7 +484,24 @@ function hashController() {\n
softwareReleaseController(query, query_kw.software_category, page)\n
}\n
}\n
\n
function cleanAjaxError(data, textStatus, jqXHR) {\n
ajax_error = $(\'#ajax_error\');\n
if (ajax_error.length > 0) {\n
ajax_error.empty();\n
}\n
}\n
\n
function processAjaxError(jqXHR, textStatus, errorThrown) {\n
ajax_error = $(\'#ajax_error\');\n
if (ajax_error.length == 0) {\n
container = $(\'#js_container\');\n
ajax_error = $(\'<div>\').addClass(\'error\').attr(\'id\', \'ajax_error\');\n
container.before(ajax_error);\n
}\n
ajax_error.empty()\n
ajax_error.html(\'There was issue with server communication. Please try to reload the page.\');\n
}
]]></string> </value>
</item>
......@@ -494,7 +511,7 @@ function hashController() {\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>15833</int> </value>
<value> <int>16369</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment