SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    setInterval : unexpected end of input?

    Hi,
    I have tried making this(showQuotes) into a function and calling the function in between the curly brackets but they didn't work either?

    Code:
    	// Show quotes from DB
    	var showQuotes = $('#single').load('quote-get-single.php');
    	
    	
    	setInterval(function(){ showQuotes },3000);
    When I insert the whole of the jQuery code in the curly's it works. How can I make this work with a var or a function ? or what is the correct way to do this.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,863
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    With showQuotes as a function to be run you run it from setInterval using:

    setInterval(showQuotes,3000);

    The only time that wouldn't work would be if showQuotes wasn't a function.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you.
    All is working now.


Tags for this Thread

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
  •