Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getCookie(name) {
- var cookieValue = null;
- if (document.cookie && document.cookie !== '') {
- var cookies = document.cookie.split(';');
- for (var i = 0; i < cookies.length; i++) {
- var cookie = cookies[i].trim();
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) === (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
- }
- $('#download').on('click', function () {
- console.log('sadsadasdas');
- $.ajax({
- url: 'download/',
- method: 'POST',
- data: {
- 'filename': filename,
- 'image_url': image_url,
- csrfmiddlewaretoken: getCookie('csrftoken')
- },
- dataType: 'json',
- success: function (response) {
- console.log(response);
- }
- });
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment