Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving data from server database in IBM worklight
    primarykey
    data
    text
    <p>I am developing an app in IBM worklight. By Ajax I have to Connect to website and retrieve data from it but it gives thisd error:</p> <blockquote> <p>Uncaught TypeError: Cannot call method 'getElementsByTagName' of null at file:///data/data/com.Test/files/www/default/Test.html:80</p> </blockquote> <p>How can I fix it? My code is this</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;script&gt;window.$ = window.jQuery = WLJQ;&lt;/script&gt; &lt;title&gt;Test&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"&gt; &lt;link rel="stylesheet" href="css/Test.css"&gt; &lt;script&gt; function loadXMLDoc() { var xmlhttp; var txt,x,i; 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 &amp;&amp; xmlhttp.status==200) { xmlDoc=xmlhttp.responseXML; txt=""; // x=xmlDoc.getElementsByTagName("Id"); var table = xmlDoc.getElementsByTagName("table"); var tds = table.getElementsByTagName("td"); alert(tds); for (var i = 0; i &lt; tds.length; i++) { alert(tds[i].innerHTML); } /* for (i=0;i&lt;x.length;i++) { txt=txt + x[i].childNodes[0].nodeValue + "&lt;br&gt;"; } */ document.getElementById("myDiv").innerHTML=txt; } } xmlhttp.open("GET","http://www.marketing.com/msb_en.html",true); xmlhttp.send(); } &lt;/script&gt; &lt;/head&gt; &lt;body id="content" style="display: none;"&gt; &lt;h2&gt;MCollection:&lt;/h2&gt; &lt;div id="myDiv"&gt;&lt;/div&gt; &lt;button type="button" onclick="loadXMLDoc()"&gt;collection&lt;/button&gt; &lt;!--&lt;input type="button" value="button name" onclick="window.open('https://www.google.com.pk')" /&gt; --&gt; &lt;!--application UI goes here--&gt; &lt;script src="js/initOptions.js"&gt;&lt;/script&gt; &lt;script src="js/Test.js"&gt;&lt;/script&gt; &lt;script src="js/messages.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and my line 80 this is </p> <pre><code>var table = xmlDoc.getElementsByTagName("table"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload