Mercurial > public > sg101
comparison downloads/static/js/downloads-get.js @ 581:ee87ea74d46b
For Django 1.4, rearranged project structure for new manage.py.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 May 2012 17:10:48 -0500 |
parents | gpp/downloads/static/js/downloads-get.js@41411066b16d |
children | f56798c96ec2 |
comparison
equal
deleted
inserted
replaced
580:c525f3e0b5d0 | 581:ee87ea74d46b |
---|---|
1 $(document).ready(function() { | |
2 $('.dl-button').each(function(n) { | |
3 var button = $(this); | |
4 var id = button.attr('id'); | |
5 var numeric_id = -1; | |
6 if (id.match(/dl-(\d+)/)) | |
7 { | |
8 numeric_id = RegExp.$1; | |
9 } | |
10 button.click(function() { | |
11 button.attr('disabled', 'disabled').val('Getting link, stand by...'); | |
12 $.ajax({ | |
13 url: '/downloads/request/', | |
14 type: 'POST', | |
15 data: { id: numeric_id }, | |
16 dataType: 'json', | |
17 success: function(result) { | |
18 var link_id = result.id; | |
19 var div = $('#link-' + link_id); | |
20 div.hide(); | |
21 div.html( | |
22 'Thank you! Your download is now ready. <a href="' + result.url + | |
23 '">Click here to download</a>.'); | |
24 div.fadeIn(3000); | |
25 }, | |
26 error: function (xhr, textStatus, ex) { | |
27 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + | |
28 xhr.responseText); | |
29 } | |
30 }); | |
31 }); | |
32 }); | |
33 }); |