Simultaneous xmlhttprequest requests failing to function properly

When attempting to send multiple XHR requests, it appears that each request is being queued and waits for the previous one to finish before proceeding. Is there a way to make simultaneous XHR requests?

$('body').delegate('.download','click', function(evt){
        evt.preventDefault(); // Not related

        var xhr = new XMLHttpRequest();
        xhr.open('GET', "proxy.php?" + this.href, true);
        xhr.responseType = 'blob';

        xhr.onload = function() {
            if (this.status == 200) {              
                var blob = new Blob([this.response], {type:'audio/mp4'});

                console.log(blob.size);
                if(blob.size > 0){
                    $("<a>").attr({
                        download: name,
                        href: URL.createObjectURL(blob),
                        target: "_blank"
                    })[0].click();
                }
            }
        };  
        xhr.send();
    });

Answer №1

There isn't much to it.

Web browsers have restrictions on:

  • The maximum number of simultaneous HTTP requests to a single source
  • The total maximum number of simultaneous HTTP requests (which is a higher limit)

By spreading out your requests among multiple sources, you may notice an increase in the imposed restriction from the initial limitation to the latter one mentioned above.

Answer №2

Discover more about the benefits of HTTP/2, with detailed information available at this resource. The HTTP/2 protocol is known for its efficient handling of parallel requests.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Selectors within 'not' in document.querySelectorAll are failing to function as expected

I've been attempting to find a way to replace the jQuery .not() function with native JavaScript, but so far my attempts using document.querySelectorAll have not been successful. Here is what I am trying to achieve - converting this jQuery selector in ...

Troubleshooting issues with JavaScript progress bar functionality

I have implemented a progress bar using HTML5, JavaScript and Ajax to showcase file uploads in PHP. The issue I am facing is that the progress bar is not displaying the progress correctly. In addition to that, the echo statements in the PHP code are no ...

Running the JavaScript function '.hover' using Selenium WebDriver

My goal is to utilize Selenium WebDriver to run some javascript code from a webpage. I have come across several helpful posts on executing javascript, but I often struggle when trying to call javascript from page objects (I am still learning the terminolog ...

What steps can be taken to address the issue of two components loading simultaneously?

While implementing page transitions with react-router-dom and react-spring's useTransitions, I encountered some bugs despite the transition animation working well. I believe CSS might help resolve these issues, but I am unsure about the exact approach ...

What is the best method for transferring files using jQuery or JavaScript?

Is there a way to use jQuery AJAX to send file information to PHP for uploading? The data in question is the file that needs to be uploaded. $.ajax({ type: "POST", url: url, data: data, /* This is where you can includ ...

Having trouble fetching JSON data using Ajax in Flask

I am working on creating a straightforward web application for displaying logs. The backend is powered by Python 3.4 and Flask, while the frontend consists of a simple web form with AJAX integration. Flask: import json from flask import Flask, jsonify, r ...

prettyPhoto popup exceeds maximum width and height limitations

I am currently using the most up-to-date version from No Margin for Errors and I have set allow_resize to true. However, the size of the display is still too large. Is there a way to set a maximum width/height? I have already configured the viewport as fo ...

Encountering a persistent GET error in the console while working on a project involving a cocktail API

Programming: const API_URL = "www.mycocktaildb.com/api/json/v1/1/search.php?s="; const $cocktailName = $('#cocktailName'); const $instructions = $('instructions'); const $form = $('form'); const $input = $(`inpu ...

Incorrect configuration file for karma

To simplify the configuration of the karma config file, I have utilized variables to store specific parts of the path. var publicfolder = "public" var mypath = "packages/vendor/package/"; files: [ publicfolder+'/assets/libs/jquery/dist/jquery.js&a ...

The flickering of the canvas is caused by jQuery .each() function

While developing a JavaScript game, I encountered an issue with a noticeable flicker on the screen whenever I used .each() to iterate through a list of bullets or enemies. Is there a way to resolve this flickering problem? function playing() { $.each(b ...

How can an additional value be sent to the form validation method?

I have created a form group like this: import { checkPasswordStrength } from './validators'; @Component({ .... export class PasswordComponent { ... this.userFormPassword = this.fb.group({ 'password': ['', [ ...

WebAPI provides a similar functionality to an array in JavaScript through the use of IQueryable

I have a WebAPI method that returns an IQueryable of a 'complex' object in the following format: [Route("api/INV_API/deptSelect")] public IQueryable<DEPTNAME_DESCR> GetDistinctDeptSelect([FromUri] string q) { if (q != null) ...

Is it possible for me to convert my .ejs file to .html in order to make it compatible with Node.js and Express?

I have an index.html file and I wanted to link it to a twitter.ejs page. Unfortunately, my attempts were unsuccessful, and now I am considering changing the extension from ejs to html. However, this approach did not work either. Do .ejs files only work wit ...

Cascade function with several parameters

I'm looking to utilize a cascade function with multiple parameters: // Cascade function (function ($) { $.fn.cascade = function (options) { var defaults = {}; var opts = $.extend(defaults, options); return this.each(functi ...

What is the reason for the position of div1 not being directly in the top right corner when its position is set to div2's top and left offset plus div2's width?

function handler(ev) { var target = $(ev.target); if( target.is(".item") ) { var brt = $(target).offset().top; var let = $(target).offset().left + $(".test").width(); $('#DivToShow').css({'top':brt,'left':let, 'd ...

Obtain the Angular 2 Form object within a TypeScript class file for manual configuration of form properties

I have a form inside a PrimeNG dialog control. I need to handle two different submit methods based on certain conditions for this form, so I don't want to use the ngSubmit method in the form tag. Instead, I want to manually access the form object in m ...

Ways to have a component in Angular 5 patiently await and receive data from another component without the use of an event signal

Seeking assistance with a dilemma involving two components (pop ups) where I need to transfer data from a child component to a parent one that lacks an event to retrieve the data. Essentially, I am looking for a way for the parent to be able to listen fo ...

Conditionally Add Columns to jQuery Datatables

I am working with a jQuery datatable to showcase data retrieved through an AJAX request. However, I am interested in adding a third column to the table specifically for administrators, allowing them to delete entries. Can someone guide me on how to incorpo ...

Achieve this effect by making sure that when a user scrolls on their browser, 50% of the content is entered into view and the remaining 50%

Is there a way to achieve this effect? Specifically, when the user scrolls in the browser, 50% of the content is displayed at the top and the other 50% is shown at the bottom. ...

Storing the selected value from a dropdown box in PHP

Can anyone help me with echoing the $row['price'] based on the user's GPU selection? Your input is greatly appreciated! #adding more content to meet word count requirements. <div id="content"> <table border="1" style="width: ...