How to call two or more ajax request parallely in php


<script>
$(document).ready(function()
{
    $(document).on("click", "._SP12_MR11", function()
    {
        var datastring = {'DSUC':SMJX_SMR_SUC,'SRCON':SMJX_SRCH_ON, 'LCNT':SMJX_SMR_LST_CNT,};

        $.when(
            $.ajax({
                url:'<?php echo base_url()."search-ax-shwmre-st";?>',
                type: 'POST',
                data: datastring,
                success:function(rta)
                {
                   // DO YPUR CODE-1
                }        
            }),
            $.ajax({
                url:'<?php echo base_url()."search-ax-shwmre-rd";?>',
                type: 'POST',
                data: datastring,
                success:function(rtb)
                {
                   // DO YOUR CODE -2
                }        
            })              
        ).then(function(){ 
              // DO AFTER TWO AJAX REQUEST CALL           
        });
     });
  });

</script>

Leave a Reply

Your email address will not be published. Required fields are marked *