Change Cursor Style before and after AJAX Request

N

nikki.farrah

Hi all, this is my first time posting so any help is appreciated! I
am doing a simple AJAX request to our server, and I would like the
cursor style changed to 'wait' when the user clicks a button which
calls the function below. After the request is complete, I would like
the style changed back. For some reason, it doesn't change the cursor
style until after the request is made, even though it's the first line
I put in the function. I tried putting it in a seperate function and
calling that in this function and in the onclick even handler, I tried
taking out the AJAX request and it works fine, etc. I know it does it
after the request because when I comment out the line setting it back
to 'auto' so it will change to 'wait' the entire time, it doesn't do
so until after the request is completed. I researched and did not find
any other users experiencing the same problem, but hopefully someone
can shed some light on the situation. Here is the function after I
deleted out the irrelevent parts. Thanks in advance!


function qaResults(){
document.body.style.cursor='wait';

***code here to find dbname and query1****

var d = new Date();
recReq = new ActiveXObject("Microsoft.XMLHTTP");

recReq.open("get", "ProduceTable.aspx?choice=queryResults&query=" +
query1 + "&dbname=" + dbname + "&timer=" + d.getTime(), false);

recReq.send();
if (recReq.readyState == 4)
{
if (recReq.status == 200)
{

document.getElementById('ResultsTable').innerHTML =
recReq.responseText;
document.getElementById('ResultsTable').style.height = "200px";
sortables_init();


}
else
alert("There was a problem retrieving HTML table:\n" +
recReq.statusText);
}


document.body.style.cursor = 'auto';

}
 
B

bruce barker

because you use the sync send, the browser cannot display the cursor as
no window loops are performed (you have stalled the ie main thread). you
can switch to async or change the cursor, and use window.setTimeout to
start the request.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top