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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:29:56+00:00 2026-05-24T11:29:56+00:00

url = http://localhost/xml.php?type=xml; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); xmlhttp.open(GET, url, true); xmlhttp.setRequestHeader(‘Content-Type’,

  • 0
url = "http://localhost/xml.php?type=xml";
if (window.XMLHttpRequest) {
      xmlhttp = new XMLHttpRequest();
      xmlhttp.open("GET", url, true);
      xmlhttp.setRequestHeader('Content-Type', 'application/xml');
      xmlhttp.send(null);
}
else if (window.ActiveXObject)  {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (xmlhttp) {
        xmlhttp.open("GET", url, true);
        xmlhttp.setRequestHeader('Content-Type', 'application/xml');
        xmlhttp.send();
    }
}

alert(xmlhttp.responseXML); //returns null

XML file

<?xml version="1.0" encoding="UTF-8" ?>
<main>
    <food>
        <type>6</type>
        <region>5676</region>
    </food>
    <food>
        <type>6</type>
        <region>5676</region>
    </food>

</main>

Anyone has idea why xmlhttp.responseXML is returning as null?

  • 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-24T11:29:57+00:00Added an answer on May 24, 2026 at 11:29 am

    Your HTTP request is asynchronous. xmlhttp.responseXML won’t have some value until xmlhttp.readyState has the value of 4.

    var url = "http://localhost/xml.php?type=xml";
    var xmlhttp;
    if (window.XMLHttpRequest) {
          xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)  {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (xmlhttp) {
        xmlhttp.open("GET", url, true);
        xmlhttp.setRequestHeader('Content-Type', 'text/xml');
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4) {
                alert(xmlhttp.responseXML);
            }
        };
        xmlhttp.send();
    }
    

    Additionaly, I don’t think you need the setRequestHeader line. XML MIME type is required for response, not for request. Also, please respect good coding practices (don’t forget var, DRY, etc.)

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

Sidebar

Related Questions

URL url = new URL(http://twitter.com/statuses/update.xml); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); String cridentials =
i am having a url like http://localhost/joomla/Joomla_1.5.7/index.php?option=com_content&view=section&layout=blog&id=3&Itemid=55 and i want to redirect this to
I'm trying to store a url such as: http://localhost/pro_print/index.php#page=home in a variable, but I
URL url = new URL(http://www.example.com/comment); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod(POST); Is connection.setRequestProperty(key,
The URL http://localhost:8080/api/xml is not showing the jobs I already confitgured. The Job node
private function loadGallery():void { theSend.url = http://localhost/userMana/file.xml; theSend.send(); } I am calling this XML
I've got the following exception while trying to open the URL http://localhost:8080/app/clientes/agregar : javax.servlet.ServletException:
So I have a local URL like http://localhost:port/ with live video stream in it.
What is the proper way to use URL parameters? My URL is this: http://localhost:8080/#pg5?testing=abc
Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using

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.