worker.js
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var old_value = '';
var xmlhttp = new XMLHttpRequest();
// web-workers are asynchrone, so we can use an infinite loop here. Normaly an infinite loop equels suicide.
while(true){
// because the XMLHttpRequest asynchrone parameter is false, the script will wait for its execution, thus, no onreadystate is necesary
// you could set it to true and watch your browser kill himself because he will open new connections one after another without waiting.
xmlhttp.open("GET", "url_to_php_script_or_whatever.php", false);
xmlhttp.send();
// there isn't any reason to return the data to the main screen if the values haven't changed
new_value = xmlhttp.responseText;
if(new_value != old_value){
old_value = new_value;
postMessage(new_value);
}
}
var xmlhttp = new XMLHttpRequest();
// web-workers are asynchrone, so we can use an infinite loop here. Normaly an infinite loop equels suicide.
while(true){
// because the XMLHttpRequest asynchrone parameter is false, the script will wait for its execution, thus, no onreadystate is necesary
// you could set it to true and watch your browser kill himself because he will open new connections one after another without waiting.
xmlhttp.open("GET", "url_to_php_script_or_whatever.php", false);
xmlhttp.send();
// there isn't any reason to return the data to the main screen if the values haven't changed
new_value = xmlhttp.responseText;
if(new_value != old_value){
old_value = new_value;
postMessage(new_value);
}
}