How to Multiple urls in one Ajax call

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.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

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.

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

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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   jQuery Multiple Email Address Validation in one text box
  2.   IMPLODE() AND EXPLODE() FUNCTION IN PHP
  3.   wordpress INSERT Multiple Rows using $wpdb
  4.   How to Get the Value of Selected Option in a Combo Box Using jQuery?
  5.   Reusable AJAX Functions (Post/Get)
  6.   Page Redirect after X seconds wait using jQuery
  7.   jQuery Ajax Get JSON in Laravel Example
  8.   Reuse Code in jquery Ajax Methods
  9.   Laravel 6 get last Insert id from query builder
  10.   GET Facebook friends list email mobile profile url using Facebook Graph API