Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
jquery set timer not working
Old 01-18-2012, 10:53 AM jquery set timer not working
Extreme Talker

Posts: 176
Trades: 0
so on the click event, when I call the function getFavicon(), it works, but on the very next line when the timer is supposed to call it it doesn't work.

Firebug says
Quote:
getFavicon is not defined
checkUrlFaviconTimer = setTimeout("getFavicon()",200);
Code:
//Favicon 
    function getFavicon() {
        $.get('/homepage/getfavicon.php', { url: $('add-link-url').val() }, function(data) {
            alert(data);
        });
    }
    
    var checkUrlFaviconTimer;
    $('input[name="add-link-url"]').click(function() {
        clearTimeout(checkUrlFaviconTimer);
        getFavicon();
        checkUrlFaviconTimer = setTimeout("getFavicon()",200);
    });

Last edited by Skeddles; 01-18-2012 at 10:55 AM..
Skeddles is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-23-2012, 12:20 PM Re: jquery set timer not working
Extreme Talker

Posts: 176
Trades: 0
Figured it out!

I think it had to do with the scope of the functions. I moved the getFavicon function out of my jquery $(document).ready (it didn't really need to be there anyway) and it now works.
Skeddles is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to jquery set timer not working
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24288 seconds with 12 queries