Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

103
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda