Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5998475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:24:42+00:00 2026-05-23T00:24:42+00:00

I have this script working with jquery and uploadify $(‘#uploader’).uploadify({ ‘uploader’ : ‘/admin/includes/uploadify/uploadify.swf’, ‘script’

  • 0

I have this script working with jquery and uploadify

      $('#uploader').uploadify({
    'uploader'  : '/admin/includes/uploadify/uploadify.swf',
    'script'    : '/admin/includes/uploadify/uploadify_storage.php',
     'scriptData': {'sessionId': sessionId},
    'cancelImg' : '/admin/includes/uploadify/cancel.png',
     'buttonImg'   : '/site_images/add_files.png',
    'folder'    :  storage,
    'auto'      : false,
    'multi'     : true,
    'fileExt'     : '*.jpg',
    'simUploadLimit' : 2,
    'wmode': 'transparent',
    'width': '150',
    'height': '20',
    'removeCompleted': false,
    'queueID'        : 'upload_queue',
    'onComplete'  : function(event, ID, fileObj, name,response, data) {

                             console.log(path);
             console.log(sub_ul);       
        }
  });

//code//


    $("li.dir > span.name").live('click', function(){
         $("span").removeClass("selected");
        var li = $(this).parent();
        var root  = $(li).attr("title");
        var folder  = $(li).find("span.name").html();
        var path = root+"/"+folder;
        path = path.replace('//', '/');
        var sub_ul = $(li).find("> ul.sub_folder");
                    set_path(sub_ul);
        $(this).addClass("selected");
    });

basically when I you click a span with .name it runs the code getting var sub_ul = $(li).find("> ul.sub_folder"); which works (its sent to set_path() ) . In a second time when I launch uploadify at the end on OnComplete the console.log(path); shows the correct value but console.log(sub_ul); returns nothing (an alert too) like the object is not specified. I can’t use objects after the JS has run? Don’t they stay saved in the DOM like path does?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:24:43+00:00Added an answer on May 23, 2026 at 12:24 am
    1. In the onComplete function that you’ve posted, you’re logging ul_sub and not sub_ul as you seem to want to.

    2. Unless in set_path() you set the value for a global variable named path, I don’t see how you would get the same value in those two different functions – the variable path within the click handler is scoped to that function and will not be accessible elsewhere. The same goes for sub_ul.

    3. I can’t use objects after the JS has run? Don’t they stay saved in the DOM like path does?

      I’m not quite sure what to make of this, JavaScript objects are not ‘saved in the DOM’. If you’re unable to access an object you’ve created, then the context must be different from the one the object was created in – it must now be out of scope and thus inaccessible. Using closure is one way to keep functions and variables accessible. Using global vars is another way to do it but is not recommended and should be avoided unless absolutely necessary.


    You might want to read these articles about scope in JavaScript to get a better idea of how things work:

    • http://coding.smashingmagazine.com/2009/08/01/what-you-need-to-know-about-javascript-scope/
    • http://www.mredkj.com/tutorials/reference_js_intro_ex.html
    • http://www.digital-web.com/articles/scope_in_javascript/

    You’ve mentioned in the comments that you’ve made a global path variable but not a sub_ul. One simple way to ‘fix’ your code is to use global variables. But again, use of global variables is generally discouraged since you could end up polluting the global namespace.

    And without seeing more of your code, it’s hard to say if this will always work correctly – for instance, your uploadify script might be triggered by events that do not cause the values of path and sub_ul to be set, which would mean that when the onComplete function runs, it’ll get the wrong values for both.

    //global vars
    var path;
    var sub_ul;
    
    $('#uploader').uploadify({
        'uploader'  : '/admin/includes/uploadify/uploadify.swf',
        'script'    : '/admin/includes/uploadify/uploadify_storage.php',
         'scriptData': {'sessionId': sessionId},
        'cancelImg' : '/admin/includes/uploadify/cancel.png',
         'buttonImg'   : '/site_images/add_files.png',
        'folder'    :  storage,
        'auto'      : false,
        'multi'     : true,
        'fileExt'     : '*.jpg',
        'simUploadLimit' : 2,
        'wmode': 'transparent',
        'width': '150',
        'height': '20',
        'removeCompleted': false,
        'queueID'        : 'upload_queue',
        'onComplete'  : function(event, ID, fileObj, name,response, data) {
                            //these will now log the values of the global vars
                            console.log(path);
                            console.log(sub_ul);       
                        }
    });
    
    //code//
    
    
    $("li.dir > span.name").live('click', function(){
        $("span").removeClass("selected");
        var li = $(this).parent();
        var root  = li.attr("title");
        var folder  = li.find("span.name").html();
        //don't redeclare path - that would shadow the global variable
        //use the global variable instead
        path = root+"/"+folder;
        path = path.replace('//', '/');
        //don't redeclare sub_ul
        sub_ul = $(li).find("> ul.sub_folder");
        set_path(sub_ul);
        $(this).addClass("selected");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this jquery voting script, everything is working fine, it just that the
I have this simple php script <?php echo '<pre>'; // Outputs all the result
I have this jquery script to call an external file. So far so good.
I have this jquery script which suppose to hide/show div element base on the
so I have this jQuery script below that works. But since I'm just learning
I have this script: select name,create_date,modify_date from sys.procedures order by modify_date desc I can
Well basically I have this script that takes a long time to execute and
I have this Perl script with many defined constants of configuration files. For example:
I have this little script to toggle a contact form when a button is
I have this .bat script which I use to maven package my application. Problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.