How to Multiple urls in one Ajax call

Today, We want to share with you How to Multiple urls in one Ajax call.In this post we will show you Multiple Ajax Requests with Jquery, hear for Multiple Simultaneous Ajax Requests (with one callback) in jQuery we will give you demo and example for implement.In this post, we will learn about multiple ajax calls simultaneously jquery with an example.

How to Multiple urls in one Ajax call

There are the Following The simple About How to Multiple urls in one Ajax call Full Information With Example and source code.

As I will cover this Post with live Working example to develop multiple ajax request on same page, so the Sending multiple ajax requests using jQuery for this example is following below.

Read Also:  Reuse Code in jquery Ajax Methods

request multiple url using ajax

var ajax1 = $.ajax({ 
  dataType: "json",
  url: "url",
  async: true,
  success: function(result) {}                     
});


var ajax2 = $.ajax({ 
  dataType: "json",
  url: "url",
  async: true,
  success: function(result) {}  
});

$.when( ajax1 , ajax2  ).done(function( a1, a2 ) {

   var data = a1[ 0 ] + a2[ 0 ]; // a1[ 0 ] = "Whip", a2[ 0 ] = " It"
   if ( /Whip It/.test( data ) ) {
      alert( "Good Luck I got what I came for!" );
   }
});

How to Run Multiple AJAX Requests

Multiple url in same ajax call

function sendMyAjax(URL_Dynamic_address){
    $.ajax({
         type: 'POST',
         url: URL_Dynamic_address,
         data: {
             answer_service: "data1 - Some Info",
             expertise_service: expertise,
             email_service: email,
         },
         success: function (data) {
             $(".display_error_msg").text(data);
         }
     });
};

How to 2urls in one Ajax call?

var first_url1 = '/api/admin/1';
var second_url2 = '/api/admin/2'
$.get(first_url1, function (r) {
    // use response from first_url1
 
    $.get(second_url2, function (r) {
        // use response from second_url2
    });
});

jquery ajax $.each and the multiple parameter form of $.ajax

Read Also:  jquery animate scrolltop - How to animate scrollTop using jQuery ?

var all_urls = ['/url/first_url','/url/second_url', ....];

$.each(all_urls, function(i,u){ 
     $.ajax(u, 
       { type: 'POST',
         data: {
            answer_service: "Some informations - 2",
            expertise_service: expertise,
            email_service: email,
         },
         success: function (data) {
             $(".display_error_msg").text(data);
         } 
       }
     );
});

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about How to Multiple urls in one Ajax call.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.