Mercurial > public > sg101
diff media/js/shoutbox.js @ 150:b43e1288ff80
Fix #33; use $.ajax instead of $.post so we can handle errors. Also, for some reason comparing objects in a template doesn't work now. Have to compare id fields.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 17 Dec 2009 04:14:16 +0000 |
parents | 3ae999b0c53b |
children | 4557974db0e0 |
line wrap: on
line diff
--- a/media/js/shoutbox.js Mon Dec 14 05:07:28 2009 +0000 +++ b/media/js/shoutbox.js Thu Dec 17 04:14:16 2009 +0000 @@ -7,10 +7,12 @@ return false; } submit.attr('disabled', 'disabled'); - $.post('/shout/shout/', { - msg: msg - }, - function (data, textStatus) { + $.ajax({ + url: '/shout/shout/', + type: 'POST', + data: { msg: msg }, + dataType: 'html', + success: function (data, textStatus) { input.val(''); if (data != '') { $('#shoutbox-shout-container').prepend(data); @@ -18,7 +20,11 @@ } submit.removeAttr('disabled'); }, - 'html'); + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + + xhr.responseText); + } + }); return false; }); var smilies_loaded = false;