Mercurial > public > sg101
diff media/js/downloads/rating.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 | 2ba1a6d3b984 |
line wrap: on
line diff
--- a/media/js/downloads/rating.js Mon Dec 14 05:07:28 2009 +0000 +++ b/media/js/downloads/rating.js Thu Dec 17 04:14:16 2009 +0000 @@ -26,8 +26,12 @@ var id = star.attr('id'); if (id.match(/star-(\d+)-(\d+)/)) { - $.post('/downloads/rate/', { id: RegExp.$1, rating: parseInt(RegExp.$2) + 1}, - function(rating) { + $.ajax({ + url: '/downloads/rate/', + type: 'POST', + data: { id: RegExp.$1, rating: parseInt(RegExp.$2) + 1}, + dataType: 'text', + success: function(rating) { rating = parseFloat(rating); if (rating < 0) { @@ -61,7 +65,11 @@ } } }, - 'text'); + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + + xhr.responseText); + } + }); } }