how to execute any function in jquery after few seconds on the click of any link

Posted by james Bond on Stack Overflow See other posts from Stack Overflow or by james Bond
Published on 2012-12-14T16:51:26Z Indexed on 2012/12/14 17:03 UTC
Read the original article Hit count: 196

Filed under:
|

I have struts2 jquery grid where on click of a row I am calling a jQuery function for performating a struts2 action. My code is running fine.

I want to perform my jQuery function after delay of a few seconds. How can I do this?

  <script type="text/javascript"> 
 //assume this code is working fine on rowselect from my jquery grid, New Updation in it is "i want to execute or load the url  after few seconds"
     $(function(){
            $.subscribe('rowselect', function(event,data) {
                var param = (event.originalEvent.id);  
                $("#myAdvanceDivBoxx").load('<s:url action='InsertbooksToSession' namespace='/admin/setups/secure/jspHomepage/bookstransaction'/>'+"?bid="+event.originalEvent.id);  
            });  
     }); 
</script>

What i tried is the below code but am unable to get the output which i am looking for:

 <script type="text/javascript">  
 $(function(){
        $.subscribe('rowselect', function(event,data) {
            var param = (event.originalEvent.id);  
            $("#myAdvanceDivBoxx").load('<s:url action='InsertbooksToSession' namespace='/admin/setups/secure/jspHomepage/bookstransaction'/>'+"?bid="+event.originalEvent.id);  
        }).delay(9000);  
 }); 
</script>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about struts2-jquery