Add Download to ajax

Asked

Viewed 233 times

0

How can I add a Download to my ajax request?

$(document).on('click', '#reg-discagem input[type="submit"]', function(e){

                  e.preventDefault(); 
var form = $('#reg-discagem');
            $.ajax({
                url: 'EnviarPedidoChamada.php',
                type: 'POST',
                data: form.serialize() 
            })
            .done(function(data){
                $('#form-content_discagem').fadeOut('slow', function(){
                    $('#form-content_discagem').fadeIn('slow').html(data);
                });
            })
            .fail(function(){
                alert('Ajax Submit Failed ...');    
            });
});
  • place the html of your form. so it is a little easier to answer the question

2 answers

2

Using ajax is even more difficult, I especially prefer to use jquery form

This is the documentation link

https://github.com/jquery-form/form

The code to send would look like this...

$('#material_form').ajaxForm({

  beforeSend: function() {        
     // $("#material_form").fadeOut(0);
     // $("#carregando_envio_material").fadeIn(0);
     // $("#progresso_envio_mateial").html("0%");
     //$("#msg_erro_envia_material").html("");    
  },
  uploadProgress: function(event, position, total, percentComplete) {

  //aqui fica a % do load.... voce pode dar o fadin e fad outa nas divs para 

  //aparecer so a partocentagem
  //$("#progresso_envio_mateial").html(percentComplete+"%");
  console.log(percentComplete);

  },
  success: function() {

  },
  complete: function(xhr) {

    //status.html(xhr.responseText);
    data = xhr.responseText;
    console.log(data);


    if(data == "sucesso"){

    }else{

    }
  }
});

anything, if this is not the correct documentation this is my scribe’s link http://b1.alunoativo.com.br/publico/js/sistema/jquery.form.js

copies the code and creates it in your files that will

-1


  • The ideal would be to answer the question right here. The link may break.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.