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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:39:05+00:00 2026-05-12T08:39:05+00:00

I would really appreciate to get your help on this, as I can’t seem

  • 0

I would really appreciate to get your help on this, as I can’t seem to detect and solve the problem I’m having with an AJAX functionality on a site that I’m currently developing.

I have a webform that makes an asynchronous call to a handler (.ashx) that delivers a XML response that is later processed by a Javascript client-side function that places it’s contents into the user-interface.

I’m attaching an example of the response generated by my handler, and what I would like to know is how can I get all the <body> element innerHTML (with the text and child nodes) contents to append it to a <span> element on the user-interface. Can anyone help me out with this?

XML Response returned by the handler (checked via Firebug):

<message>
    <content>
        <messageId>2</messageId>
        <from>Barack Obama</from>
        <fromMail>barack.obama@whitehouse.gov</fromMail>
        <subject>Yes, we can... get World Peace</subject> 
        <body>Hello, dear citizen. I'm sending you this message to invite you to join us! <a href="http://www.whitehouse.gov">Test link</a> Thank you for your time.</body>
    </content>
</message>

Client-side Javascript function to affect the user-interface innerHTML property with the data returned via AJAX:

function GetMessageContentsCallback(args, resp) {
    //XML Parser
    try {
        //Internet Explorer
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = "false";
        xmlDoc.loadXML(resp);
    }
    catch (e) {
        parser = new DOMParser();
        xmlDoc = parser.parseFromString(resp, "text/xml");
    }
    var msgReply = xmlDoc.getElementsByTagName('message')[0];
    var ajaxRespondeBodyInnerHTML = msgReply.getElementsByTagName(body)[0].firstChild.nodeValue;
    //this currently only delivers inner text content, without the <a href... bit and subsequent text
    document.getElementById("bodySpan").innerHTML = ajaxRespondeBodyInnerHTML;
}
  • 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-12T08:39:05+00:00Added an answer on May 12, 2026 at 8:39 am

    You have the right idea, but you have a syntax error. I tested and found the problem is with this line as expected:

    var ajaxRespondeBodyInnerHTML = msgReply.getElementsByTagName("body")[0].firstChild.nodeValue;
    

    body is not in quotes.

    See http://jsbin.com/ufubo/edit for a working example.

    Edit: Also, if you want to have HTML in your XML, you need to nest your content in CDATA tags. I’ve updated the example to show this.

    Edit: I’ve update the example and saved it…

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

Sidebar

Related Questions

I would really appreciate your help in this. I have been trying to get
I would really appreciate if you could shed light on this problem. I have
I would really appreciate any help with the following problem: I need to be
Hey there. I would really appreciate your help in creating a query that would
Would really appreciate some help with this. I have an app which consists of
I would really appreciate any suggestions, no matter how simple or complex, to help
I would really appreciate it if some of you could help optimize my tables,
I would really appreciate if you would take a look at this piece of
I'm very new to C++ and would really appreciate any and all help. I
I would really appreciate some feedback on what I am trying to achieve: The

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.