Click here to Skip to main content
16,012,468 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
This Is my API URL:

https://noc.iglass.net/LOGIN?credential_0=mohan.rao&credential_1=********&destination=%2Fjglass%2Fcpe%2FaccountCpeDataApi.do%3Fcust%3Datl-fl%26init%3D1%26account%3D8783200010007088

AND XMl OUTPUT is shown Below:

<accounts>

<account>

<id>8783200010007088</id>

<address>100 W SAN MARINO DR, MIAMI BEACH</address>

<node>MIA-58</node>

<cpes>

<cpe>

<mac>00:1d:d6:77:ac:89</mac>

<type>p</type>

<responder><font color="green">Online</font></responder>

<health><span class="green_text">RxPwr&nbsp;=&nbsp;3.5</span>, <span class="green_text">TxPwr&nbsp;=&nbsp;42.3</span>, <span class="green_text">UpSNR&nbsp;=&nbsp;35.1</span>, <span class="green_text">DwnSNR&nbsp;=&nbsp;35.2</span></health>

<flap>N/A</flap>

<bw><font color="green">Up=8.71MB Down=1.45MB</font></bw>

<battery><font color="green">Good</font></battery>

<device>ts-1-mia-(d50:0.11m)-(50:14)</device>

<custom-billing>

<Name>
                  DONALD ALTMAN
               </Name>

<Type>
                  M6
       </Type>

</custom-billing>

</cpe>

</cpes>

</account>

</accounts>

I want to hit this API From Javascript. from my XML Output Iwant to read Responder tag Innertext  "Online".

My Code is shown Below:

<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc(id)
{
var xmlhttp;
var txt,x,i;
var url="https://noc.iglass.net/LOGIN?credential_0=mohan.rao&credential_1=5cm7U@Mw&destination=%2Fjglass%2Fcpe%2FaccountCpeDataApi.do%3Fcust%3Datl-fl%26init%3D1%26account%3D"+id;
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 && xmlhttp.status==200)
    {
    xmlDoc=xmlhttp.responseXML;
    txt="";
    x=xmlDoc.getElementsByTagName("responder");
    for (i=0;i<x.length;i++)
      {
      txt=txt + x[i].childNodes[0].nodeValue + "<br>";
      }
    document.getElementById("myDiv").innerHTML=txt;
    }
  }
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>
</head>

<body>
<div id="myDiv"></div>
<input type="text" id="txtid" size="40"/>
<button type="button" onclick="loadXMLDoc(txtid.value)">Check Modem</button>

</body>
</html>

Here Am using one Textbox and one button when the button is clicking i want to pass textbox value into the API and then i want to show the status like "online" or "offline" from the responder TAG.

Now the problem is,

Am getting the needed outout from the above code but it is only working in "IE".API is not hitting properly in firefox and chrome.

How can i solve this problem or suugest me any other way to get output?
Posted

1 solution

I advise that you should adopt jquery.
It's very convenient to handle ajax .
click the following link:


http://api.jquery.com/jQuery.ajax/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900