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 7499127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:42:42+00:00 2026-05-29T19:42:42+00:00

I’m loading a comment list and try to replace the list I currently have

  • 0

I’m loading a comment list and try to replace the list I currently have on my html page with the new loaded one.

Previously, my version was to load the list (which was simple xml), iterate over its elements and generate my content.
It worked well, but I had to iterate and create the elements one by one, and the xml thing was useless, except for debug.

Now, I’m trying to change the xml page so that we can view it either as html (standalone) or as xml (for ajax needs, i.e. only the core thing).

I replace it like that :

// ajax call to populate the comments
    $.ajax({
        type: 'GET',
        url: 'flow/' + target,
        dataType: 'xml',
        success: function(xml){
                var list = $(xml).find('#flow');

                // var $list = $layer.find('#flow');
                // $list.children().remove();
                // we process it for events :
                //  --to implement--

                // we simply replace the list
                $layer.find('#flow').replaceWith(list);

                // update the scrollpane
                updateScrollPane();
        },
        error: function(xhrq, status, code){
            formError('Could not load the comments.<br />Error with xhr : status=' + status + ', code=' + code);
            // and we log it
            log('Error with xhr : status=' + status + ', code=' + code);
            updateScrollPane();
        }
    });

But the problem is that it gets inserted correctly, but it’s considered as xml by the browser and therefore styling doesn’t work correctly.

i.e. here is a possible list which gets loaded :

<?xml version="1.0"?>
            <ul id="flow" path="2012/grammont" target="IMG_9610.JPG" valid="false">
<!-- no comment yet, be the first ! -->
                <li class="no-comment" />
<!-- Log : 
New FlowDB(2012/grammont/flow.db, IMG_9610.JPG)
 -->
            </ul> <!-- end of the real content -->

I guess my problem is that it is wrongly interpreted by jquery as xml (but I used $(xml).find(‘#flow’), so it should only get the DOM elements and put the xml header away…).

Currently, the correct li elements are HTMLLIElement objects, while the one which I get inserted are of simple type Element (i.e. not interpreted by the browser).

How do I make sure the browser gets it as html and not mixed elements from xml ?

Edit :

if I try to generate simple html without the xml header, and load it with no dataType (or dataType: ‘html’), the result is even worse because my current list is deleted, and nothing is put to replace it…

  • 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-29T19:42:44+00:00Added an answer on May 29, 2026 at 7:42 pm

    XML elements are not the same as HTML elements (they actually carry an empty xmlns attribute when inserted in the DOM, so the browser will not consider them as styleable HTML elements, even if the node names appear to be the same).

    Since you’re working with HTML data, you should instruct jQuery to load the markup as HTML, not XML:

    $.ajax({
        type: "GET",
        url: "flow/" + target,
        dataType: "html",
        // ...
    });
    

    And maybe use HTML5 data attributes so you can embed additional information in your markup without making it invalid:

    <ul id="flow" data-path="2012/grammont"
        data-target="IMG_9610.JPG" data-valid="false">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I used javascript for loading a picture on my website depending on which small
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.