Jquery Ajax - During upload - show real-time return date

Asked

Viewed 138 times

3

I want the user to be able to track the progress of each shipment in an application. I have on one side, sending via ajax, and with php I perform a foreach for batch sending. For example, select id 1,2,3,5,7, and press send. I want to show on the screen in real time, "sending id1"...." sending id2", each in its respective moment... We can think of 2 stages to be displayed: Sending id2...id2 sent.. and so on.. Sending id3... id3 sent. As this is in a foreach, it will occur in batch successively until all the user selects.

I tried so:

$("form").submit(function(){
    $.ajax({
        type: "POST",
        url: "arquivo-foreach.php",
        data: dados,
        beforeSend: function(data){
            $(".box").html(data);
        },
        success: function( data ){
            $(".box").html(data);
        }//end success
    });//end method
    return false;
});//end submit

I get the result of all those sent after the whole process is completed, but it does not appear one at a time while it is being sent.. Would anyone know how?

  • I believe that if you want this control item by item should make a POST for each data... Another way would be through socket, but it’s much more work. Or create another method just to return these status and consult in a range you define.

  • But what would that look like in the code? Because I tried beforeSend the way I posted it, and the result only appears in Success.. then wonder how it would work for each one to be shown in their respective time...

  • Some kind of console use.log... some idea?

  • I tried with console.log.. but it does not appear on the screen..

No answers

Browser other questions tagged

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