Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Resume the Ajax upload form when the Internet is connected

When the user's internet is connected, the upload is done and while uploading, the internet is suddenly disconnected and the form upload is failed.(status = (failed)net::ERR_INTERNET_DISCONNECTED , Type = xhr)

Is there a code that resumes the upload form after connecting to the Internet?

This is my upload code that is sent as Ajax:

$('#form_upload_create').submit(function (e) {
e.preventDefault();
$form = $(this)
var formData = new FormData(this);
$.ajax({
    url: window.location.pathname,
    type: 'POST',
    data: formData,
    cache: false,
    contentType: false,
    processData: false,
    success: function (response) {
           alert(response.message)
        }
    },
    xhr: function () {
        //upload Progress
        var xhr = $.ajaxSettings.xhr();
        if (xhr.upload) {
            xhr.upload.addEventListener('progress', function (event) {
                var percent = 0;
                var position = event.loaded || event.position;
                var total = event.total;
                if (event.lengthComputable) {
                    percent = Math.ceil(position / total * 100);
                }
                //update progressbar
                $(".progress-bar").css("width", +percent + "%");
                $(".status").text(percent + "%" + 'waiting upload...');
            }, true);
        }
        return xhr;
    },
});

});

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!