Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
Handling error on form submit javascript/jquery/ajax/angularjs

I went through existing questions regarding this topic but I was not able to find a solution for my case. I am new to javascript, jquery. I have this code

let form = angular.element('form');
          form.attr('action', url);
          form.attr('method', 'get');
          form.attr('name', filename);
          if (fieldName != null) {
            $('<input type="hidden" name = "field" value = "' + fieldName + '"/>').appendTo(form);
          }
          form.trigger('submit');

the url is an api call. This performs download of a file. I am trying to handle if there is an error for which I tried using ajax, jquery

let form = angular.element('form');

 form.submit(function(){
            $.ajax({
              async: false,
              url: url,
              type: 'GET',
              cache: false,
              success: function(resp) {             
              },
              error: function(error) {
                toaster.error(error.responseText);
              }
            });
          });
form.trigger('submit');

this creates multiple(three in my case) toasters. and every subsequent error will just double the number of toasters. if I pass the url and type as form.attr() the error: block code does not get represented on the screen. How do I display the toaster on the screen or make the ajax call execute once? I am not using anchor element to download because it is causing some other problems. so using form.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda