Mercurial > public > sg101
diff media/js/gcalendar_edit.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 | dbd703f7d63a |
children |
line wrap: on
line diff
--- a/media/js/gcalendar_edit.js Mon Dec 14 05:07:28 2009 +0000 +++ b/media/js/gcalendar_edit.js Thu Dec 17 04:14:16 2009 +0000 @@ -3,12 +3,22 @@ if (confirm('Really delete this event?')) { var id = this.id; if (id.match(/gcal-(\d+)/)) { - $.post('/calendar/delete/', { id : RegExp.$1 }, function (id) { - var id = '#gcal-' + id; - $(id).parents('li').hide('normal'); - }, 'text'); + $.ajax({ + url: '/calendar/delete/', + type: 'POST', + data: { id : RegExp.$1 }, + dataType: 'text', + success: function (id) { + var id = '#gcal-' + id; + $(id).parents('li').hide('normal'); + }, + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + + xhr.responseText); + } + }); } } return false; - }); + }); });