diff options
author | makkalot <makkalot@gmail.com> | 2008-08-06 01:13:35 +0300 |
---|---|---|
committer | makkalot <makkalot@gmail.com> | 2008-08-06 01:13:35 +0300 |
commit | fd7271a25fb26e15378e4a73546f83bd1e34459f (patch) | |
tree | 6c0fabb5973e1ce0b45df0d92d443c12e0523b33 /funcweb | |
parent | 10feb6034a6965022867b9ce9234b60e60aba27e (diff) | |
download | func-fd7271a25fb26e15378e4a73546f83bd1e34459f.tar.gz func-fd7271a25fb26e15378e4a73546f83bd1e34459f.tar.xz func-fd7271a25fb26e15378e4a73546f83bd1e34459f.zip |
some error handling code for post ajax requests
Diffstat (limited to 'funcweb')
-rw-r--r-- | funcweb/funcweb/static/javascript/ajax.js | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/funcweb/funcweb/static/javascript/ajax.js b/funcweb/funcweb/static/javascript/ajax.js index 21a3815..d61608a 100644 --- a/funcweb/funcweb/static/javascript/ajax.js +++ b/funcweb/funcweb/static/javascript/ajax.js @@ -86,7 +86,24 @@ function makePOSTRequest(source, url, target, parameters, options) { } if (http_request.status == 200) { if(target) { - target.innerHTML = http_request.responseText; + var is_error = true; + //some hacky olution to catch the python errors + try{ + var check_error = evalJSON(http_request.responseText); + } + catch(e){ + //There is no error in request + is_error = false; + } + if (is_error == true){ + if (compare(check_error['fg_flash'],null)!=0) + connection_error(check_error['tg_flash']); + else + is_error = false; + } + + if (is_error == false) + target.innerHTML = http_request.responseText; } //success if (options['on_success']) { @@ -96,9 +113,15 @@ function makePOSTRequest(source, url, target, parameters, options) { //failure if (options['on_failure']) { eval(options['on_failure']); - } else { + //it seems to be an expiration ... + } else if(http_request.status == 403){ + alert('It seems that current session expired you should log in !'); + window.location = window.location.href; + } + else { alert('There was a problem with the request. Status('+http_request.status+')'); } + } //complete if (options['on_complete']) { |