0

But now I have other problem. I dont know how to get value from cwok from XML each 5 second

XML Files

<user name="Name1" status="online" ip="0.0.0.0">
 <stats>
   <cwok>100</cwok>
   <cwnok>0</cwnok>
   <cwignore>0</cwignore>
 </stats>
</user>
<user name="Name2" status="online" ip="0.0.0.0">
 <stats>
   <cwok>200</cwok>
   <cwnok>0</cwnok>
   <cwignore>0</cwignore>
 </stats>
</user>

Highcharts script to read data from XML

 // Load the data from the XML file
 $.get('oscamapi.html?part=userstats', function(xml) {

     // Split the lines
     var $xml = $(xml);

     // push series
     $xml.find('user').each(function(i, series) {

          var seriesOptions = {
              name: $(series).attr('name'),
              data: []
              };

          // push data points
          $(series).find('stats cwok').each(function(i, point) {
                  seriesOptions.data.push(
                          parseInt($(point).text())
                   );
          });

         // add it to the options
         options.series.push(seriesOptions);
     });
     var chart = new Highcharts.Chart(options);
   });
});

Thanks for your idea and help

krishwader
  • 11,341
  • 1
  • 34
  • 51
skyndas
  • 265
  • 4
  • 16
  • I beleive you have to do some kind of setinterval function for this, here is a post setting up a ajax call to repeat every 10 seconds. http://stackoverflow.com/questions/5687600/jquery-call-ajax-every-10-seconds – Bearcat9425 Jun 04 '13 at 20:42

1 Answers1

0

You need to call ajax in setInterval(), and then get data. I assume that you would like to get data from secong user section:

    <user name="Name2" status="online" ip="0.0.0.0">
 <stats>
   <cwok>200</cwok>
   <cwnok>0</cwnok>
   <cwignore>0</cwignore>
 </stats>
</user>

So you can use the same parser for XML but with modified user lines:

$xml.find('user[name="Name2"]')

AJAX:

 chart:{
    events:{
       load:function(){
          setInterval(function(){
              $.ajax()...
          },1000);
       }
    }
}
Sebastian Bochan
  • 37,348
  • 3
  • 49
  • 75