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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:19:07+00:00 2026-06-11T23:19:07+00:00

I have a standard, simple AJAX query in IE (using an Msxml2.XMLHTTP ActiveX object)

  • 0

I have a standard, simple AJAX query in IE (using an Msxml2.XMLHTTP ActiveX object) which requests an ASPX page in the same domain. While the responseText field contains the complete HTML, in IE the responseXML field is blank (this works just fine in Chrome).

As part of my debugging process, I stripped the ASPX page down to a bare bit of XML, and I even ran it through an XML validator to be sure I hadn’t mistyped anything. I changed the content-type of the ASPX page to “text/xml” (IE identifies the page as an XML Document in the page properties) and the encoding to “utf-8” (both at the page level and via the globalization tag in the web.config).

When my web service returns the exact same content, the AJAX code has no trouble with it. Aslo, the AJAX has no trouble reading an XML file (containing an exact duplicate of the content) within the same project. It’s only the ASPX page it can’t seem to parse.

I’ve had nothing but trouble with the UpdatePanels (ASP.NET 3.5), so I’m going with the pure javascript approach.

Any suggestions? Am I missing something?

AJAX Code

    function NavigateResults(query) {

        var xmlHttp;

        try {
            xmlHttp = new XMLHttpRequest();
        } catch (e) {

            // These are utilized for Microsoft IE browsers
            try {
                //alert('Boy... you should consider upgrading your browser.');
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    //alert('Whoa... no, seriously, you really need to upgrade!!!');
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                    //alert("Yikes! Your browser does not support AJAX! Your inter-webs are broken! Call a 15-year old ASAP!");
                    window.location = url;
                    return false;
                }
            }

        }

        if (xmlHttp !== null) {
            xmlHttp.onreadystatechange = function() {
                if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                    response = xmlHttp.responseXML;
                    var l_stringNode;
                    try {
                        l_stringNode = response.selectNodes("div")[0];
                    } catch (e) {
                        try {
                            l_stringNode = response.evaluate("div")[0];
                        } catch (e) {
                            l_stringNode = null;
                        }
                    }

                    alert("Response Text:\n\n" + xmlHttp.responseText);
                    alert("Response XML:\n\n" + xmlHttp.responseXML.xml);

                    //document.getElementById("SearchResultsDiv").innerHTML = xmlHttp.responseText;

                    if (l_stringNode !== null && l_stringNode.firstChild !== null) {
                        try {
                            var serializer = new XMLSerializer();
                            document.getElementById("SearchResultsDiv").innerHTML = serializer.serializeToString(l_stringNode);
                        } catch (e) {
                            // IE does not support serializeToString
                            document.getElementById("SearchResultsDiv").innerHTML = l_stringNode.xml;
                        }
                    }
                }
            }

            var url = prompt("URL", "http://localhost:6168/Test.xml"); // + query + "&contType=xml");
            xmlHttp.open("GET", url, true);
            //prompt("URL", "http://localhost:4511/Service1.asmx/Autocomplete?prefix=test");
            //xmlHttp.open("GET", "http://localhost:4511/Service1.asmx/Autocomplete?prefix=test", true);
            xmlHttp.send(null);
        }

    }

Test XML (copied from Test.aspx via View Source, exactly matches the XML file and the response from the web service)

<?xml version="1.0"?>
<ul>
  <li>Testacea</li>
  <li>Testament</li>
  <li>Testudinata</li>
</ul>
  • 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-06-11T23:19:08+00:00Added an answer on June 11, 2026 at 11:19 pm

    Ok, I finally figured it out. A typically ASPX page has page information at the top, followed by content, like this:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
    <?xml version="1.0"?>
    <ul>
      <li>Testacea</li>
      <li>Testament</li>
      <li>Testudinata</li>
    </ul>
    

    That page information actually creates a blank line at the top of the output, which results in invalid XML (the xml declaration MUST be on the first line if it’s present at all). So, there are two solutions. One, move the xml declaration onto the same line, like so:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %><?xml version="1.0"?>
    

    Two, remove the xml declaration completely.

    You must still set the content-type to text/xml.

    protected void Page_Load( object sender, EventArgs e ) {
        this.Response.ContentType = "text/xml";
        this.Response.ContentEncoding = System.Text.Encoding.UTF8;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple page that returns an ajax success/error message on submission. The
I have a standard select box which I'm populating using jquery by appending options,
I have a really standard splash screen, just a simple Default.png, but for whatever
I have standard source code package under Linux which requires to run ./configure make
Is it possible to have standard war deployment, which can be deployed on tomcat
I have a simple ajax call like this: $.ajax({ url: u, type: POST, dataType:
I have a simple HTML form that uses uses ajax in part of the
I have a simple ASP.Net MVC View which contains an FCKeditor text box (created
I have a very simple and standard PHP force download script. How do I
I have a simple HTML-page with a UTF-8 encoded link. <html> <head> <meta http-equiv="content-type"

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.