Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery XML via AJAX: missing some nodes occasionally
    primarykey
    data
    text
    <p>I have a flot graph that polls data via <code>ajax</code> from an XML document. I use mode: <code>time for x axis</code>. It works fine, except intermittently, some values from the <code>xml Document</code> gets dropped. Here is the code that fetches <code>xml</code> via <code>ajax</code>.</p> <pre><code>function graphUpdate() { $.ajax( { url: "EnergyDM.xml", type:"GET", dataType: "XML", success: onxmlReceived, error: function(xhr, textStatus, errorThrown) { alert(textStatus + ' ' + errorThrown); } }); // setTimeout(graphUpdate,10000); } function onxmlReceived(data) { var xmlData = null; //for Non IE Browsers if(window.DOMParser) { //xmlData = data; parser = new DOMParser(); xmlData = parser.parseFromString(data, "text/xml"); } // For IE else { xmlData = new ActiveXObject("Microsoft.XMLDOM"); xmlData.async = false; xmlData.loadXML(data); } $(xmlData).find('energyDM').each(function(){ Rec_Count = parseInt($(this).find('edNum').text()); d1=[]; for(var i = 0; i &lt; Rec_Count; i++) { if(i &lt; 10) { d1.push([(parseInt($(this).find('et000'+i).text(),10))*1000, parseFloat($(this).find('ed000'+i).text())]); } else if(i &lt; 100) { d1.push([(parseInt($(this).find('et00'+i).text(),10))*1000, parseFloat($(this).find('ed00'+i).text())]); } else { d1.push([(parseInt($(this).find('et0'+i).text(),10))*1000, parseFloat($(this).find('ed0'+i).text())]); } } plotWithOptions(); }); } </code></pre> <p>The XML file looks like this:</p> <pre><code>&lt;energyDM&gt; &lt;edNum&gt;305&lt;/edNum&gt; &lt;TMF&gt;UTC &lt;/TMF&gt; &lt;pm339&gt; 1.271&lt;/pm339&gt;&lt;!-- pm339 max energy demand value --&gt; &lt;pm340&gt;1325033716&lt;/pm340&gt;&lt;!-- pm340 max energy demand occured time --&gt; &lt;ed0000&gt; 0.282&lt;/ed0000&gt; &lt;et0000&gt;1325545093&lt;/et0000&gt; &lt;ed0001&gt; 0.283&lt;/ed0001&gt; &lt;et0001&gt;1325544792&lt;/et0001&gt; &lt;ed0002&gt; 0.284&lt;/ed0002&gt; &lt;et0002&gt;1325544492&lt;/et0002&gt; ... &lt;ed0305&gt; 0.284&lt;/ed0305&gt; &lt;et0305&gt;1325544492&lt;/et0305&gt; &lt;/energyDM&gt; </code></pre> <p>When the returned XML misses nodes, if I use Chrome to view the values, it shows something like: </p> <pre><code> &lt;ed0023&gt; 0.283&lt;/ed0023&gt; &lt;et0023&gt;1325538176&lt;/et0023&gt; &lt;ed0024&gt; 0.281&lt;/ed0024&gt; &lt;et0024&gt;1325537875&lt;/et0024&gt; &lt;ed0035&gt; 0.281&lt;/ed0035&gt; &lt;et0035&gt;1325534564&lt;/et0035&gt; &lt;ed0036&gt; 0.280&lt;/ed0036&gt; &lt;et0036&gt;1325534263&lt;/et0036&gt; </code></pre> <p>And this does not always happen. If I keep refreshing the page, it may drop few nodes, then the whole thing comes up, etc. And it is not always the same nodes getting dropped either.</p> <p>I'd appreciate any hints.</p>
    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