Using ajax to trigger multiple ajax requests at the same time

use ajax to trigger multiple ajax requests at the same time

for example, if there are 10 get requests, I want them to trigger at the same time and request at the same time.

Mar.11,2021

copy 10 directly, or write a loop


var result1;
var result2;
$.when(
    $.ajax({ // First Request
        url: form_url, 
        type: form_method,      
        data: form_data,     
        cache: false,
        success: function(returnhtml){     
                result1 = returnhtml;                  
        }           
    }),

    $.ajax({ //Seconds Request
        url: form_url, 
        type: form_method,      
        data: form_data,     
        cache: false,
        success: function(returnhtml){                          
            result2 = returnhtml;     
        }           
    })

).then(function() {
    $('-sharpresult1').html(result1);
    $('-sharpresult2').html(result2);
});

write 10 in order


write a parameter passing method and call it 10 times

Menu