Hi Everyone,
I have been playing with JavaScript few days now. I have a php script that returns data in XML. I want my Dashboard (html) page to show the response back from my php file. Since this is going to be a Dashboard hence it needs to refresh the content every second hence using JavaScript.
I want to get some guides, tutorials, or how-to for this. Any help would be much appreciated.
Here is what I get from my .php file if I do a POST method to it and define variable “extension=9999” to it:
<?xml version="1.0" encoding="utf-8"?>
<reseller>
<history>
<extension>9999</extension>
<duration>0</duration>
<cost>0</cost>
</history>
<history>
<extension>9999</extension>
<duration>0</duration>
<cost>0</cost>
</history>
<history>
<extension>9999</extension>
<duration>1</duration>
<cost>9</cost>
</history>
<history>
<extension>9999</extension>
<duration>0</duration>
<cost>0</cost>
</history>
<history>
<extension>9999</extension>
<duration>0</duration>
<cost>0</cost>
</history>
<history>
<extension>9999</extension>
<duration>0</duration>
<cost>0</cost>
</history>
</reseller>
How can above be nicely presented in an HTML using JavaScript and how would this query be refreshed and re-POSTED every 1 second?
P.S. Amount of XML data coming back to me is dynamic. So, I don’t know how much data I get back. Sometime nothing. Sometime 4 childs. Sometime 10 childs in the XML.
thanks very much
Here’s an article that explains how it can be done.
Using XML Data Traversal » SitePoint Blogs
Thanks a lot.
Few things though.
1- It’s not doing a POST method to get data.
2- It works only in IE? Am I right with that assumption?
3- It doesn’t refresh every 1 second.
Can you please shed some light on the above 3. I have used quite a few scripts like this but I am failing when I try to enhance them to POST method or Refresh every second…
Thanks
Have you considered using a code library such as jQuery to help remove the complexity for you?
I don’t think this is that complex as jQuery might yet get me into another learning curve. I would like to have a quicker turn around time for this.
It just that JavaScript is not anything like PHP
and I don’t have much experience with it.
Keep in mind that we are all volunteers here. I am heading off in the next hour or so, so won’t be able to help significantly with your issue. I might see though if I can put something together when I return tomorrow, but even so it would be to guide you through what’s needed, so that you can learn from the process of doing it too.
Oh, I definitely appreciate all the guide from you. And definitely want to learn the processes rather than copying my work.
But for some reason JavaScript is really not my thing
I don’t know why it’s has such an ugly syntax (no offense to anyone who likes JavaScript). I think that plays into my not being so motivated on it. But again not a lot of resources on JavaScript are available like is on PHP, HTML, etc…
In the meanwhile I will do a bit searching on jQuery as well.
Regards,