Parallel AJAX request without jQuery

Related searches

I am trying to fetch multiple parallel request with single callback, just like jQuery "when"

$.when(ajax1, ajax2).done(callback)

I don't want to call the second ajax call after ajax1 is completed, I want ajax2 and ajax2 to be requested same time and than the callback when both are completed.

I'm looking for plain javascript instead of jQuery for such implementation.

Use a method to make the request that will return a promise.

This could be simply using the fetch api or wrapping XMLHttpRequest with a promise.

Put the two promises in an array and pass it to Promise.all.

Promise.all([ fetch(""), fetch("") ])
    .then(array => console.log(array));

Parallel asynchronous Ajax requests using jQuery, Try this solution, which can support any specific number of parallel queries: var done = 4; // number of total requests var sum = 0; /* Normal loops don't create a� Without jQuery, well there are a few things to be aware off before starting. The XMLHttpRequest Object. To make an ajax request we use the XMLHttpRequest object.

You can also use async/ await with Promise.all to achieve that:

async function getAll() {
  // waits untill all resposnes are resolved
  const data = await Promise.all([
    fetch('').then(response =>
    fetch('').then(response =>
  // returns array of resolved data from fetch


Multiple Simultaneous Ajax Requests (with one callback) in jQuery , How to process multiple parallel AJAX requests with the use of and allowing dynamic content changes without the need of reloading the whole page. And this is why we'll talk about the AJAX in the conjuction with jQuery� Luckily, for those dead-set on using jQuery for this type of call, there are a few plug-ins that will “fix” jQuery in this regard. Essentially, the plug-ins must override jQuery’s ajax request sending/handling logic via the $.ajaxTransport method. But, sending ajax requests in IE8/9 is pretty simple without jQuery.

You can replace done to then Method

$.when( ajax1 , ajax2 ).then(function() {
    // success ajax1, success ajax 2

How to use AJAX events for parallel requests, Instead you can create a new XMLHttpRequest() object for each request if you want it to run in parallel. Example: var Ajax = { request : function (� $.ajax () is an asynchronous function which initiates a request and then returns immediately. So if you call it multiple times in a row, it will create concurrent requests. Your code still runs on a single thread, but the HTTP requests happen in parallel in the background and jQuery invokes your callbacks as they return data.

Ajax without jQuery - JavaScript, Execute multiple AJAX request parallel without waiting for others to respond: jQuery.when() provides a way to execute callback functions based on zero or more� Tagged with rail, ajax, jquery. AJAX (Asynchronous JavaScript and XML), which gained serious traction in mid-2000s, is a set of techniques consisting of sending asynchronous (hence “A”) requests between the browser and the application server, containing XML objects (hence “X”) with the use of JavaScript (hence “J”) and allowing dynamic content changes without the need of reloading

How to multiple AJAX requests be run simultaneously in jQuery?, In this case you should utilize a new function that will plot an area out, then use the callback functions of the ajax request to pass the data to that function. For example: $(document).ready(function() { function plotArea(data, status, jqXHR) { // access the graph object and apply the data.

This, coupled with the jQuery.when method, allows you to easily add handlers to handle either the successful completion of all AJAX requests, or the failure of one; without the need for you to track anything yourself!

  • This will throw an error because $ isn't defined. The question very clearly was asking for a solution which does not use jQuery.
  • Sorry, I'm not using jQuery.