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

248
Vistas
Retrieve ajax variable from JQuery AjaxForm plugin

Here my code:

let xhr;

function uploadFile() {
    const bar = $("#progressUpload");
    const dialog = $("#modalUpload");
    const alertOk = $("#alertUploadOk");
    const btnClose = $("#btnClose");
    const btnAbort = $("#btnAbort");

    dialog.modal("show");
    btnClose.prop("disabled", true);
    btnAbort.prop("disabled", false);

    xhr = $("#formUploadConfig").ajaxForm({  // <--- does not store the Ajax call
        beforeSubmit: function() {
            let percentVal = '0%';
            bar.width(percentVal)
            bar.html(percentVal).attr('aria-valuenow', percentVal);
        },

        uploadProgress: function(event, position, total, percentComplete) {
            let percentVal = percentComplete + '%';
            bar.width(percentVal)
            bar.html(percentVal).attr('aria-valuenow', percentVal);
        },

        success: function(response) {
            let percentVal = '100%';
            bar.width(percentVal)
            bar.html(percentVal).attr('aria-valuenow', percentVal);
            alertOk.show();
        },

        complete: function(xhr) {
            if (xhr.responseText) {
                btnClose.prop("disabled", false);
                btnAbort.prop("disabled", true);
            }
        },

        abort: function () {
            alert("aborted");
        }
    });
}

My goal is to store the Ajax call in order to call xhr.abort(); as needed. If I was using the standard ajax function I was simple:

var xhr = $.ajax({ ...

but now I'm trying to use the JQuery AjaxForm plugin and I don't understand how to retrieve this variable.

over 4 years ago · Santiago Trujillo
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