Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
149:ab7830b067b3 | 150:b43e1288ff80 |
---|---|
5 var msg = $.trim(input.val()); | 5 var msg = $.trim(input.val()); |
6 if (msg.length == 0) { | 6 if (msg.length == 0) { |
7 return false; | 7 return false; |
8 } | 8 } |
9 submit.attr('disabled', 'disabled'); | 9 submit.attr('disabled', 'disabled'); |
10 $.post('/shout/shout/', { | 10 $.ajax({ |
11 msg: msg | 11 url: '/shout/shout/', |
12 }, | 12 type: 'POST', |
13 function (data, textStatus) { | 13 data: { msg: msg }, |
14 dataType: 'html', | |
15 success: function (data, textStatus) { | |
14 input.val(''); | 16 input.val(''); |
15 if (data != '') { | 17 if (data != '') { |
16 $('#shoutbox-shout-container').prepend(data); | 18 $('#shoutbox-shout-container').prepend(data); |
17 $('#shoutbox-shout-container p:first').fadeIn(2500); | 19 $('#shoutbox-shout-container p:first').fadeIn(2500); |
18 } | 20 } |
19 submit.removeAttr('disabled'); | 21 submit.removeAttr('disabled'); |
20 }, | 22 }, |
21 'html'); | 23 error: function (xhr, textStatus, ex) { |
24 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + | |
25 xhr.responseText); | |
26 } | |
27 }); | |
22 return false; | 28 return false; |
23 }); | 29 }); |
24 var smilies_loaded = false; | 30 var smilies_loaded = false; |
25 var smiley_frame = $('#shoutbox-smiley-frame'); | 31 var smiley_frame = $('#shoutbox-smiley-frame'); |
26 $('#shoutbox-smilies').click(function () { | 32 $('#shoutbox-smilies').click(function () { |