SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How can I stop AJAX PeriodicalUpdater

    Hi SitePoint

    I'm not having any luck with stopping an Ajax.PeriodicalUpdater function, Prototype 1.5.0. My function looks like this and I call it on window.onload:

    Code:
    function fileuploadStatus() {
    
    var u = new Ajax.PeriodicalUpdater( 'statusDisplay', 'returnStatus.lasso', { method: 'get', parameters: 'fw_s=sid', frequency: 2 } );
    }
    When I read the documentation on http://www.prototypejs.org/api/ajax/periodicalUpdater I get the impression I should be able to call fileuploadStatus.stop() - for example in a link like this:
    <a href="#" onclick="fileuploadStatus.stop();">stop</a> but it doesn't work, I get "stop is not a function" back from the browser debugger.

    I'm missing something obvious here - can somebody enlighten me?

    /nikolaj
    Music&Media
    Web Solutions for Cultural Businesses

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you'd need to call u.stop(), but 'u' will be local in scope to your function, if you need it to be global then lose the 'var' (and, I'd suggest, change the name to something a little more recognisable)

  3. #3
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Hmm... I'm still missing something

    Hi Jones,

    Thank you for chiming in

    I'm apparently still missing something obvious, my function now looks like this:

    Code:
    		function fileuploadStatus() {
    			statusUpdater = new Ajax.PeriodicalUpdater(
    				'statusDisplay',
    				'returnStatus', {
    					method: 'get',
    					parameters: 'fw_s=sid',
    					frequency: 2
    				}
    			);
    		}
    but I still can't call the function like this:

    <a href="#" onclick="statusUpdater.stop();">stop</a>

    As I would have expected. I get "statusUpdater not defined" back in console.

    Of course my problems are due to my mediocre knowledge of Javascript - I thought I had it enough under the hood to crack this one. But apparently not...
    Music&Media
    Web Solutions for Cultural Businesses


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
  •