views:

81

answers:

1

I have a long-running database query that I've placed in an asynchronous AJAX callback (or so I think) to allow the user to navigate to another page if they're not interested in the results.

Whether I call the query automatically after page load or on click, the page always locks up until it returns, i.e links and buttons don't work. Internet Explorer 6's own menus are fine however, so it's not that IE itself is overworked.

What could I be doing wrong? It seems as though my request isn't really asynchronous. Here is a code snippet:

this.XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
this.XmlHttp.open("POST", url, true);
this.XmlHttp.send(data);
A: 

It's not the browser that blocks the page, it's the server.

IIS only handles one request at a time from each user. As the user already has a request from the AJAX call that the server is working on, the new request will be queued until the first request is handled.

To keep the long running request from blocking the user on the server you have to make the page that the AJAX call gets session-less. That way it's not associated to the user.

Guffa
Oh! Is there no way of doing it while keeping the session? We need sessions on every page for authentication.
a_a
Plus if I'm just, say, trying to select something from a drop-down menu, isn't that purely client-side? The drop-down list can't even be viewed until the unrelated request has finished, so I don't get to the stage of issuing a request.
a_a
No, if you keep the session, you are limited to one request per user. You don't show how you take care of the response in your code. Is it really asynchronous (i.e. using a callback function), or are you just using a loop to wait for the response?
Guffa
I think the problem was that I didn't realise the content had to be contained in an UpdatePanel. It seems to be working now. Thanks for your help!
a_a
That doesn't really make sense... What you have is not an ASP.NET AJAX call, so it doesn't use an UpdatePanel...
Guffa
Once I put my database query in an event handler triggering an update to the contents of an UpdatePanel, the rest of the UI was freed up for user interaction. The event handler uses AJAX.
a_a