This is a migrated thread and some comments may be shown as answers.

AJAX Request Queue - blocking calls

3 Answers 146 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 15 Aug 2011, 04:11 PM
Hi

I have a problem with one AJAX call blocking another.  I suspect that I don't really fully understand what's going on "under the hood/bonnet" to know if I can fix this behaviour so would appreciate a full explanation if one exists, or better still a way to fix the behaviour.

Scenario
I have a page that displays a list of products.  Most of the information for these products is quick to get from the database, but stock data requires calls to 3rd party systems.

The solution is to load the page quickly with the majority of the data.  As soon as the page has loaded, an AJAX call is automatically fired to retrieve stock information that takes between 5-10 seconds.

Meanwhile, the Shopper can click on a button that also does an AJAX call back - the call is very quick and the results are displayed in a Tooltip (think that fact is probably irrelevant).

The initial problem was that when the Shopper clicked on the button, it cancelled the call to get stock.  I got around that problem by setting the RequestQueueSize property to be a number greater than 0.

Problem
If the Shopper spends 10 seconds reading the page and then clicks on the button, they see their results load almost instantaneously - this is because the Stock data has been returned.  However, if the shopper clicks on the button as soon as they page has loaded, then they will have to wait until the long-running call to get the stock information has completed.

My understanding ...
I thought that the whole point of being asynchronous was that once the JavaScript engine had sent the Request off to the server, it would then be free to handle other jobs in the queue.  Once the Response was received from the Server, it would then be added to the queue.

This being the case, it should work as follows:
  1. Request for stock sent
  2. Request for button-click sent
  3. Response for button-click received (and processed)
  4. Response for stock received (and processed)

However, it appears that the second Request is not sent until the first Response has been received.
I thought that a "standard" browser could have a maximum of two connections to a single domain (HTTP Limits) so if nothing else is occuring on my page then this should work as expected.

So is Telerik RadAjaxPanel managing a single queue and only firing off a Request if the previous Request has already been returned?

If so, then from the link regarding HTTP connection limits, there really ought to be two queues per domain.

Think I need that explanation....

Many thanks in advance!

Griff

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 17 Aug 2011, 02:57 PM
Hello Jonathan,

By design ASP.NET AJAX Framework cancels the ongoing ajax request if you try to initiate another one prior to receiving the response from the first one.
By setting the RequestQueueSize property to a value greater than zero, you are enabling the queueing mechanism of RadAjax, that will allow you to complete the ongoing request and then initiate the pending requests in the control queue.
However the browsers does not allow to have two post request to the server at the same time. So per this reason when the first one started it is necessary to wait for its response so the second one to be posted to the server.
This is the default behaviour not only for controls ajaxified with RadAjax. No matter if the second request will take less time it will be sent only after the first (longer one in your case) finishes.
This behaviour is the default browser and framework behaviour and could not be avoid.

Regards,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
M
Top achievements
Rank 1
answered on 17 May 2019, 03:12 PM

Hello world

Is there a workaround for this? It's almost 8 years later?

@Maria you are saying: "However the browsers does not allow to have two post request to the server at the same time." I've tried a $.get() request but unforunately there is the same problem. So seems there is no difference between post or get request in KENDO framework?

 

@Jonathan if you have found a solution I would be glad to hear how you could solve this! 

0
M
Top achievements
Rank 1
answered on 17 May 2019, 03:14 PM

Hi @Jonathan

 

If you have found a solution I would be glad to hear how you could solve this! 

Thank you, 

Regards M

Tags
General Discussions
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
M
Top achievements
Rank 1
Share this question
or