summaryrefslogtreecommitdiffstats
path: root/install/static/ipa.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-09-29 16:17:03 -0500
committerAdam Young <ayoung@redhat.com>2010-09-29 21:44:39 -0400
commitc82b4d91bf344ad731c2efef0bde1b4db9f59210 (patch)
tree0d046229ea572ec02ce5fff2b1edda179e5b1529 /install/static/ipa.js
parent6477bc26df073ae237d1b46d35891071fecf826d (diff)
downloadfreeipa-c82b4d91bf344ad731c2efef0bde1b4db9f59210.tar.gz
freeipa-c82b4d91bf344ad731c2efef0bde1b4db9f59210.tar.xz
freeipa-c82b4d91bf344ad731c2efef0bde1b4db9f59210.zip
Checking empty AJAX response in ipa_cmd().
Some errors (e.g. server down) are reported as AJAX success with empty data. The ipa_cmd() has been modified so that it will detect such errors and invoke the error handler.
Diffstat (limited to 'install/static/ipa.js')
-rw-r--r--install/static/ipa.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/install/static/ipa.js b/install/static/ipa.js
index 25a3f1bb7..9e84bb9e0 100644
--- a/install/static/ipa.js
+++ b/install/static/ipa.js
@@ -56,10 +56,10 @@ function ipa_init(url, use_static_files, on_win, on_error)
$.ajaxSetup(ipa_ajax_options);
ipa_cmd('json_metadata', [], {},
- function(data, status, xhr) {
+ function(data, text_status, xhr) {
ipa_objs = data.result.metadata;
ipa_messages = data.result.messages;
- if (on_win) on_win(data, status, xhr);
+ if (on_win) on_win(data, text_status, xhr);
},
on_error
);
@@ -75,10 +75,26 @@ function ipa_init(url, use_static_files, on_win, on_error)
* objname - name of an IPA object (optional) */
function ipa_cmd(name, args, options, win_callback, fail_callback, objname)
{
+ function ipa_success_handler(data, text_status, xhr) {
+ if (!data) {
+ var error_thrown = {
+ name: 'HTTP Error '+xhr.status,
+ message: data ? xhr.statusText : "No response"
+ }
+ ipa_error_handler(xhr, text_status, error_thrown);
+
+ } else if (win_callback) {
+ win_callback(data, text_status, xhr);
+ }
+ }
+
function ipa_error_handler(xhr, text_status, error_thrown) {
ipa_dialog.empty();
ipa_dialog.attr('title', 'Error: '+error_thrown.name);
- ipa_dialog.append('<p>'+error_thrown.message+'</p>');
+
+ if (error_thrown.message) {
+ ipa_dialog.append('<p>'+error_thrown.message+'</p>');
+ }
ipa_dialog.dialog({
modal: true,
@@ -120,7 +136,7 @@ function ipa_cmd(name, args, options, win_callback, fail_callback, objname)
var request = {
url: url,
data: JSON.stringify(data),
- success: win_callback,
+ success: ipa_success_handler,
error: ipa_error_handler
};