Mercurial > public > sg101
comparison media/js/shoutbox_app.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 | 777451a98f9d |
children |
comparison
equal
deleted
inserted
replaced
149:ab7830b067b3 | 150:b43e1288ff80 |
---|---|
9 }); | 9 }); |
10 $('a.shout-del').click(function () { | 10 $('a.shout-del').click(function () { |
11 if (confirm('Really delete this shout?')) { | 11 if (confirm('Really delete this shout?')) { |
12 var id = this.id; | 12 var id = this.id; |
13 if (id.match(/^shout-del-(\d+)/)) { | 13 if (id.match(/^shout-del-(\d+)/)) { |
14 $.post('/shout/delete/', { id : RegExp.$1 }, function (id) { | 14 $.ajax({ |
15 url: '/shout/delete/', | |
16 type: 'POST', | |
17 data: { id : RegExp.$1 }, | |
18 dataType: 'text', | |
19 success: function (id) { | |
15 var id = '#shout-del-' + id; | 20 var id = '#shout-del-' + id; |
16 $(id).parents('tr').fadeOut(1500, function () { | 21 $(id).parents('tr').fadeOut(1500, function () { |
17 $('div.shoutbox-history table tr:visible:even').removeClass('odd'); | 22 $('div.shoutbox-history table tr:visible:even').removeClass('odd'); |
18 $('div.shoutbox-history table tr:visible:odd').addClass('odd'); | 23 $('div.shoutbox-history table tr:visible:odd').addClass('odd'); |
19 }); | 24 }); |
20 }, 'text'); | 25 }, |
26 error: function (xhr, textStatus, ex) { | |
27 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + | |
28 xhr.responseText); | |
29 } | |
30 }); | |
21 } | 31 } |
22 } | 32 } |
23 return false; | 33 return false; |
24 }); | 34 }); |
25 $('.shout-flag').click(function () { | 35 $('.shout-flag').click(function () { |
28 id = RegExp.$1; | 38 id = RegExp.$1; |
29 if (confirm('Only flag a shout if you feel it is spam, abuse, violates site rules, ' + | 39 if (confirm('Only flag a shout if you feel it is spam, abuse, violates site rules, ' + |
30 'or is not appropriate. ' + | 40 'or is not appropriate. ' + |
31 'A moderator will be notified and will review the shout. ' + | 41 'A moderator will be notified and will review the shout. ' + |
32 'Are you sure you want to flag this shout?')) { | 42 'Are you sure you want to flag this shout?')) { |
33 $.post('/shout/flag/', { id : id }, function(response) { | 43 $.ajax({ |
34 alert(response); | 44 url: '/shout/flag/', |
35 }, 'text'); | 45 type: 'POST', |
46 data: { id : id }, | |
47 dataType: 'text', | |
48 success: function(response) { | |
49 alert(response); | |
50 }, | |
51 error: function (xhr, textStatus, ex) { | |
52 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + | |
53 xhr.responseText); | |
54 } | |
55 }); | |
36 } | 56 } |
37 } | 57 } |
38 return false; | 58 return false; |
39 }); | 59 }); |
40 }); | 60 }); |