Is it possible that 2 jQuery-ajax are running at the same time on the same page?

I tried to run 2 JQuery-ajax at the same time, but it seems like it was always doing the first JQuery-ajax before the second JQuery-ajax. Just wandering around, is it possible that 2 jQuery-ajax are running at the same time on the same page?

For instance:

I have created a page that will allow the user to insert a batch of records into the database, and on the same page it has a table to display all the data inside the database.

I am using setInterval to call a function and to retrieve data with JQuery-ajax every 5 seconds. The recovered data will be displayed on the screen, which means that this data will be updated every 5 seconds on the screen.

When I clicked a process button on the same page to insert a batch of records into the database using jQuery-ajax (the process may take 2 minutes to complete). At this point, the screen will be able to update the displayed data on the screen after the insert process is complete, even the ones I set setInterval to fetch the data using jQuery-ajax every 5 seconds.

Does anyone know what is going wrong here? or Is it so that I can submit 2 JQuery-ajax and execute their task at the same time?

0


a source to share


3 answers


A in Ajax means asynchronous. So really, by definition, you should be able to run multiple requests at the same time. (LogicFlux)



Here's a blog that talks about it.

+2


a source


Browsers have two http connections per server limit , this can be changed in firefox in about: config and, that is, in the registry windows (I don't know where)



In your case, perhaps the db server is blocking the read request because a write transaction is taking place that locks the table.

+1


a source


I had the same problem but with JavaScript. I had two instances of async $ .ajax () that ran once, but the first one had "success: window.location =" www.google.pl ";

If the first instance finished, it tried to redirect to a new location. But the second copy still worked.

This is the reason for this error.

0


a source







All Articles