<progress id = "progressBar" max = "100" value = "%! port-adc2"></progress>
02-06-2013, 06:56 AM
haulin
I didn't read it all, but it seems, that it should execute a pre-defined function, if it finds the %! symbol combination. I don't know, why it doesn't work. Maybe try to omit the doublequotes or make a space after it, so the %! stands alone surrounded by whitespace. Or maybe it will do it only once on the page. However, they encouraged that meta-tag approach, too. It appears, you can even omit the URL part and it will refresh itself. Did you try the JS method with setTimeout line?
02-06-2013, 07:18 AM
cseb
yes i have tried with setTimeout line but then the links on the webpage doesnt work. my webpage sends data to the circuit by these links. with the settimeout line the page refreshes and these links doesnt work.
by the way i have learned ajax alittle bit, and edited the code like below:
after the first click on the chage buton the progress bar disappears and doesnt go back?
02-06-2013, 08:14 AM
haulin
Ok, if there's some more stuff on the page, then probably AJAX is the way. I'm guessing trouble with adc.shtml, what are the exact contents of it? If it is a whole webpage with headers and stuff, that might be the culprit. By using innerHTML you force the browser to parse again all the contents of it. If you want to add just text, you should go with nodeValue:
also, you don't have to worry about IE5/6/7, as these do not support <progress> anyway. You could replace it with just variable width <div> (rectangle), if you need to support them.
02-06-2013, 08:24 AM
cseb
the exact contents of adc.shtml is %! port-adc2 .
02-06-2013, 08:35 AM
cseb
ok , i have edited the code and it works now. the last thing is how to omit the change buton and load this function forever auto :)
Code:
<script>
function loadXMLDoc()
{
var xmlhttp;
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)
{
document.getElementById("demo").childNodes[ 0 ].nodeValue=xmlhttp.responseText;
}
}
xmlhttp.open("GET","adc.shtml",true);
xmlhttp.send();
}
</script>
02-06-2013, 09:15 AM
haulin
Well, i'd go with the setInterval again, since you can decide when to stop sending the requests. Use the exact same JS as in post #18, but add the function call to the else branch: