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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:41:03+00:00 2026-05-26T04:41:03+00:00

Hi I am trying to work on a script to get back XML text

  • 0

Hi I am trying to work on a script to get back XML text from a php site. However, it is not returning any data. Here is what I am doing.

<head>
<script type="text/javascript">
function getImei()
{
var imei = document.getElementById("imeiInput").value;
if (imei=="")
  {
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }


  xmlhttp.onreadystatechange = function()
  {
  if (xmlhttp.readyState==4)
    {
    document.getElementById("txtResult").innerHTML=xmlhttp.responseText;
    }
  } 


xmlhttp.open("GET","http://www.phonesite.com/xml/api/phone.php?IMEI=" + imei,true);
xmlhttp.send();


}
</script>
</head>
<body>
    <input type="textbox" id="imeiInput"/>
    <input type="button" onClick="getImei()" id="btnSubmit" text="Submit"/>
    <p id="txtResult"></p>
</body>
</html>

When I do it this way xmlhttp.readystate stops at 1. When I put the “xmlhttp.onreadystatechange = function()” below the xmlhttp.send(), it says the ready state is 4 in FireBug but it completely jumps over the function without going inside of it and finishes.

Also, I did try to enter in the url with the query string directly into my browser and it returned text. Looked at the GET request and they are the same when the Javascript sends it out and when I enter it in.

Date    Fri, 14 Oct 2011 01:34:05 GMT
Server  Apache
Content-Encoding    gzip
Vary    Accept-Encoding
Content-Length  87
Keep-Alive  timeout=15, max=100
Connection  Keep-Alive
Content-Type    text/xml
Request Headersview source
Host    www.phonesite.com
User-Agent  Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection  keep-alive

I get this error in firebug for the xml text.

XML Parsing Error: no element found Location: moz-nullprincipal:{baefeeae-cd08-9641-a08f-6b3c3396e8a7} Line Number 1, Column 1:
  • 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-26T04:41:04+00:00Added an answer on May 26, 2026 at 4:41 am

    when you request the responce back from the server to be XML not just text you read that response using responseXML

    instead of "responseText"; you need for xml "responseXML"
    

    this will at least return back the text and get you on your way

     function getImei()
     {
    
     if (window.XMLHttpRequest)
       {// code for IE7+, Firefox, Chrome, Opera, Safari
       xmlhttp=new XMLHttpRequest();
       }
     else
       {// code for IE6, IE5
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
       }
    
     var imei = document.getElementById("imeiInput").value;
     if (imei=="")
       {
       return;
       }
    
     if(xmlhttp) {
     xmlhttp.open("GET","http://www.phonesite.com/xml/api/phone.php?IMEI=?" + imei, true); 
    
     xmlhttp.onreadystatechange = function()
     {
     if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
     document.getElementById("txtResult").innerHTML=xmlhttp.responseText; // if the returned           content type is is "text/xml" innerhtml will strip out the tags
    
     }
     }
     xmlhttp.send(null);
     }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send data from PHP to a bash script and then
I am trying to get this script to work. it opens up a directry
I'm trying to get an expect script to work, and when I use the
I'm trying to get an array of strings or an object back from a
I have been trying everything I can to get this script to work and
I am trying to get AutoComplete to work on a website application I am
I am trying to import product reviews from an older site to our new
http://www.queness.com/post/328/a-simple-ajax-driven-website-with-jqueryphp I'm trying to get the above script to work, but with some changes.
I'm trying to get a stored procedure to work for a co-worker who is
I've got a test site here (still in development) and I'm trying to get

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.