avaaren

addad

May 12th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  function getCookie(name) {
  2.             var cookieValue = null;
  3.             if (document.cookie && document.cookie !== '') {
  4.                 var cookies = document.cookie.split(';');
  5.                 for (var i = 0; i < cookies.length; i++) {
  6.                     var cookie = cookies[i].trim();
  7.                     // Does this cookie string begin with the name we want?
  8.                     if (cookie.substring(0, name.length + 1) === (name + '=')) {
  9.                         cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  10.                         break;
  11.                     }
  12.                 }
  13.             }
  14.             return cookieValue;
  15.         }
  16.  
  17.         $('#download').on('click', function () {
  18.             console.log('sadsadasdas');
  19.             $.ajax({
  20.                 url: 'download/',
  21.                 method: 'POST',
  22.                 data: {
  23.                     'filename': filename,
  24.                     'image_url': image_url,
  25.                     csrfmiddlewaretoken: getCookie('csrftoken')
  26.                 },
  27.                 dataType: 'json',
  28.                 success: function (response) {
  29.                     console.log(response);
  30.                 }
  31.             });
  32.         });
  33.     });
  34. </script>
Advertisement
Add Comment
Please, Sign In to add comment