469,647 Members | 1,789 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

Change Cursor Style before and after AJAX Request

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.heig ht = "200px";
sortables_init();
}
else
alert("There was a problem retrieving HTML table:\n" +
recReq.statusText);
}
document.body.style.cursor = 'auto';

}

Apr 3 '07 #1
1 2785
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)
ni**********@gmail.com wrote:
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.heig ht = "200px";
sortables_init();
}
else
alert("There was a problem retrieving HTML table:\n" +
recReq.statusText);
}
document.body.style.cursor = 'auto';

}
Apr 3 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Stefan Mueller | last post: by
1 post views Thread by arash | last post: by
1 post views Thread by chamitha | last post: by
reply views Thread by =?Utf-8?B?SmltSGVhdmV5?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.