Execution sequence inside a jquery event handler

Posted by user576358 on Stack Overflow See other posts from Stack Overflow or by user576358
Published on 2011-01-18T03:00:50Z Indexed on 2011/01/18 3:53 UTC
Read the original article Hit count: 166

Filed under:

I have a big issue with the execution squence inside this jquery handler : Was wondering if anyone has come accross this before:

I have a simple form:

<form action='foo.cgi' id='myForm' >
<input type=text name='name' />
<input type=submit value='Find it!'/>
</form>

when user clicks on Find it! would like to change the cursor to 'progress' before the data is returned through an ajax call:

    $(document).ready(function(){

  $("#myForm ").submit(function(){

   $("body").css("cursor", "progress") ;

   htmlobj=$.ajax({url:server_url,..........);

   }

 }

However: The cursor [line 2 above ] does not change until data is returned through ajax - Seems like line 3. gets executed before 2.

Any help is greatly appreciated

© Stack Overflow or respective owner

Related posts about jQuery