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

99
Views
Show alert when ajax file is not uploaded

There is no problem with uploading files in the ajax code below. However, I have a question regarding the code below. For example, is there a way to report an error with ajax when the upload is rejected by the server?

For example, I am getting the following error report in my browser's developer console.

"An error occurred trying to load the resource."

Is there a way to show this error in alert()? Or can we show an alert() message when we encounter such an error?

$(document).on("change", "#files", function(e) {
        e.preventDefault();
        var values = $("#values").val();
        var id = $("#files").attr("data-id");
        var data = { upload: id };
        $("#uploadform").ajaxForm({
            type: "POST",
            data: data,
            delegation: true,
            cache: false,
            async: false,
            beforeSubmit: function() {
               alert('Uploading');
            }, 
            success: function(response) {
                alert('Success!');
            },error:  function(){
               alert('Can not uploaded');  
            }
        }).submit();
    });
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!