tags:

views:

271

answers:

2

I tried to run 2 JQuery-ajax at the same time, but it's seem always done the 1st JQuery-ajax before the 2nd JQuery-ajax. Just wandering, is it possible for 2 JQuery-ajax working at the same time for the same page?

For example:

I created a page which will allows the user to insert a batch of records into the database, and at the same page it have a table to display all data inside the database.

I have use setInterval to call a function and to retrive the data with JQuery-ajax every 5 sec. The retrived data than will display on the screen, which means those data will be update every 5 sec on the screen.

When I pressed a process button in the same page to insert batch of records into the database with JQuery-ajax (it may take 2 mins to finish the process). At this point, the screen will only able to update the display data on the screen after the insert process is completed even those I had set setInterval to retrive the data with JQuery-ajax every 5 sec.

Does anyone know what is going wrong here? or It's any way that I can submit 2 JQuery-ajax and do thier task at the same time?

+1  A: 

The A in Ajax stands for Asynchronous. So really, almost by definition you should be able to have multiple requests running simultaneously. (LogicFlux)

Here's a blog post that goes into some discussion on this matter.

Ólafur Waage
+1  A: 

Browsers have a two http connections per server limitation, this can be changed in firefox in the about:config, and in ie in windows registry (not sure where)

In your case, maybe the db server is blocking the reading request because there a writing transaction going on that locks the table.

Pablote