worker.js

Gesponsorde koppelingen

PHP script bestanden

  1. worker.js
  2. web_worker.html

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
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);
    }
}

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.