SHARE
TWEET

Untitled

a guest Jun 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. python:
  2.  
  3.  
  4. @app.route('/task_status', methods=['POST'])
  5. def check_task_status():
  6.     print(f'str(request.json data form server) - {str(request.json)}')
  7.  
  8.  
  9. js:
  10.  
  11.  
  12.     (function ($) {
  13.     $(document).ready(function () {
  14.         let job_id = {"job_id": getUrlParameter('task')};
  15.         JSON.stringify(job_id);
  16.         console.log(job_id);
  17.         let SetIntervalId = setInterval(function () {$.ajax(
  18.             {
  19.                 type: 'POST',
  20.                 url: '/task_status',
  21.                 data: JSON.stringify(job_id),
  22.                 dataType: "json",
  23.                 success: function (response) {
  24.                     if (response['status'] === 'SUCCESS') {
  25.                         $("#download_btn").prop("disabled", false);
  26.                         clearInterval(SetIntervalId);
  27.                     } else if (response['status'] === 'FAILURE') {
  28.                         clearInterval(SetIntervalId);
  29.                         alert('Task is failed!')
  30.                     } else {
  31.                     }
  32.                 }
  33.             })
  34.         }, 1000);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top