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

  • Home
  • SEARCH
  • 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 178143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:10:47+00:00 2026-05-11T14:10:47+00:00

I’m new to JQuery and web development in general. I’m trying to load some

  • 0

I’m new to JQuery and web development in general. I’m trying to load some data from an XML file and build an unordered list. I’ve got that part working, now I’m trying to use the TreeView plugin so I can collapse/expand the data. The data is loaded like this:

$(document).ready(function(){     $.ajax({         type: 'GET',         url: 'solutions.xml',         dataType: ($.browser.msie) ? 'text' : 'xml',         success: function(data) {             var xml;             if (typeof data == 'string') {                 // Work around IE6 lameness                 xml = new ActiveXObject('Microsoft.XMLDOM');                 xml.async = false;                 xml.loadXML(data);             } else {                 xml = data;             }              list = ''             $(xml).find('Group').each(function() {                 group = $(this).attr('name');                 list += '<li><span>' + group + '</span><ul>';                  $(this).find('Solution').each(function() {                     solution = $(this).attr('name');                     list += '<li><span>' + solution + '</span></li>';                });                 list += '</ul></li>';             });              $('#groups').html(list);                    },          error: function(x) {             alert('Error processing solutions.xml.');         }     });      $('#groups').treeview({         toggle: function() {             console.log('%s was toggled.', $(this).find('>span').text());         }     }); }); 

and the HTML looks like this:

<html>   ...   <body>     <ul id='groups'>     </ul>   </body> </html> 

The unordered list shows correctly, but the little [+] and [-] signs don’t show up and the sections aren’t collapsible/expandable. If I get rid of my Ajax loading and insert an unordered list inside of #groups manually it works as expected.

What am I doing wrong? Is there any other plugins or Javascript libs that could make this easier? The solution needs to work on IE6 locally (i.e. webserver).

Update: I found a work-around: If I define my treeview stuff like this it works:

function makeTreeview() {     $('#container').treeview({         toggle: function() {             console.log('%s was toggled.', $(this).find('>span').text());         }     }); } setTimeout('makeTreeview();', 50); 

I think the problem is, when I create the treeview, the ajax stuff hasn’t done it’s work yet, so when treeview() is called, the unordered list hasn’t been created yet. I haven’t tested this with IE6 yet. Is there a nicer way to do this, without using SetTimeout()?

  • 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. 2026-05-11T14:10:47+00:00Added an answer on May 11, 2026 at 2:10 pm

    I made the same type of call for another project. For other reasons you will probably want to wrap your ajax call in an anonymous function to create a closure so that your variables remain what you expect them to…

    The success method is a callback function that happens after your call is complete , just create your treeview inside that method, or break it out into a seperate fumction if you need to for clarity.

    in the example that you show – your treeview will still fail if the ajax call takes longer than 50ms – which could easily happen during initial load if more than two objects are being loaded from that same server.

    This example used JSON, and concurrently loaded html data from a page method into a series of divs.

    $(document).ready(function() {  for (i= 1;i<=4;i++)  {  (function (){      var divname ='#queuediv'+i;       $.ajax({        type: 'POST',        contentType: 'application/json; charset=utf-8',        dataType: 'json',        url: 'test12.aspx/GetHtmlTest',        data: '{}',        error: function(xhr, status, error) {            alert('AJAX Error!');        },         success: function(msg) {          $(divname).removeClass('isequeue_updating');          $(divname).html(msg);          $('#somethingfromthemsg').treeview();        }      }); })();  }  }); 

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 263k
  • Answers 263k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The FileSystemObject is made for local disc files ONLY. Try… May 13, 2026 at 11:59 am
  • Editorial Team
    Editorial Team added an answer I use ILMerge to merge my assemblies into one, then… May 13, 2026 at 11:59 am
  • Editorial Team
    Editorial Team added an answer I'd first convert Adapter.AddNewBlogCategoryReturnID(categoryName, ref categoryID) so that instead of… May 13, 2026 at 11:59 am

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.