Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- python:
- @app.route('/task_status', methods=['POST'])
- def check_task_status():
- print(f'str(request.json data form server) - {str(request.json)}')
- js:
- (function ($) {
- $(document).ready(function () {
- let job_id = {"job_id": getUrlParameter('task')};
- JSON.stringify(job_id);
- console.log(job_id);
- let SetIntervalId = setInterval(function () {$.ajax(
- {
- type: 'POST',
- url: '/task_status',
- data: JSON.stringify(job_id),
- dataType: "json",
- success: function (response) {
- if (response['status'] === 'SUCCESS') {
- $("#download_btn").prop("disabled", false);
- clearInterval(SetIntervalId);
- } else if (response['status'] === 'FAILURE') {
- clearInterval(SetIntervalId);
- alert('Task is failed!')
- } else {
- }
- }
- })
- }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement