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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:43:38+00:00 2026-05-17T00:43:38+00:00

I need to load xml file from specified url using javascript. Here is what

  • 0

I need to load xml file from specified url using javascript. Here is what i am doing:

function GetXMLDoc() {
    var url = 'http://www.warm.fm/exports/NowOnAir.xml';
    var httpRequest = null;
    try {
        httpRequest = new ActiveXObject('Msxml2.XMLHTTP'); 
    }
    catch (e) {
        try {
            httpRequest = new ActiveXObject('Microsoft.XMLHTTP'); 
        }
        catch (e2) {
            try {
                httpRequest = new XMLHttpRequest(); 
            }
            catch (e3) { httpRequest = false; }
        }
    }
    if (httpRequest) {
        httpRequest.open('POST', url, false);
        httpRequest.setRequestHeader("Content-Type", "text/xml");
        httpRequest.send(null);
        alert(httpRequest.responseText);
    }
    else {
        alert(httpRequest);
    }

It works perfectly in IE but it does not in FF and Google Chrome. Firebug shows me the following error:

uncaught exception: [Exception… “Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]” nsresult: “0x80004005 (NS_ERROR_FAILURE)” location: “JS frame :: http://localhost:49697/XMLParser.js :: GetXMLDoc :: line 43″ data: no]

Is there anyone who has the answer that will help me in solving the issue?

Thanks,
Mohin

  • 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-17T00:43:39+00:00Added an answer on May 17, 2026 at 12:43 am
        httpRequest.open('POST', url, false);
        httpRequest.setRequestHeader("Content-Type", "text/xml");
        httpRequest.send(null);
    

    This doesn’t really make sense. You’re doing a POST and claiming that you’re sending an XML file as the request body, but then sending nothing.

    I suggest you really want to do a simple GET:

        httpRequest.open('GET', url, false);
        httpRequest.send();
    

    Naturally you will have to do this from a document on www.warm.fm to satisfy the same origin policy; localhost won’t work.

    And I would seriously reconsider the synchronousness of the request (open...false). This is freeze the browser whilst the file is fetched, which is pretty user-hostile. Asynchronous requests with an onreadystatechange callback are almost always preferable.

    Also, the cross-browser xmlhttprequest stuff is a bit old fashioned, and tries ActiveXObject first. Native XMLHttpRequest is usually the one to go for first. Try this IE6 fallback code instead:

    if (!window.XMLHttpRequest && 'ActiveXObject' in window) {
        window.XMLHttpRequest= function() {
            return new ActiveXObject('MSXML2.XMLHttp');
        }
    }
    

    then you can just do new XMLHttpRequest() on any browser.

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

Sidebar

Related Questions

I need to load a .xml file from a URL adress into an NSData
I have a dynamic products xml file that i need to load from an
I need to load an xML file from the bin folder in ASP.NET (MVC,
my web application has an xml file here: /files/xml/test.xml I need to load a
I need to load xml from a file into an XmlDocument. The problem is
I need to modify a (xml-)file from Apache Ant. loadfile task allows to load
I need to load an XML source using Simple XML, duplicate an existing node
I am making a simple javascript application where I need to load an xml
I am using Javascript to load XML and transform it with XSLT. Everything works
I'm in a new project where I need to load XML files from other

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.