Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement