SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2011
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with using the timeout function to set a delay

    I'm trying to delay this line by 1 second, but can't seem to figure out the syntax.
    Code:
    window.location.href="index.php?vid_id="+<?php echo $vid_id +1 ?>;
    this is the entire function
    Code:
    $('#cancel').click(function() {
    			$.ajax({
    		    type: "POST",
    		    url: "scripts/greenlight.php?vid_id="+<?php echo $vid_id ?>,
    		    data: "vote=2",
    		    success: function(){
    		    }});
    			document.getElementById("greenlight").src="img/greenlight_btns/greenlight_btn.png";
    			document.getElementById("cancel").src="img/greenlight_btns/cancel_btnOver.png";
    			//window.location.href="index.php?vid_id="+<?php echo $vid_id +1 ?>
    			window.setTimeout(function() 
    			{  
        			window.location.href="index.php?vid_id="+<?php echo $vid_id +1 ?>;  
    			}, 1000);
    			
    			}); // end click

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Try it by 10 seconds instead - you should then be able to easily determine if what you're doing works or not.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •