title: PHP Asyncronous call to Objects Methods
body: <p>Is there any way to make asyncronous calls to PHP objects methods? Using jquery I could .load en external file into div, but then I wouldnt be able to access methods like setTemp below. I want to avoid having to "wait" for one object to update before the second update is initiated..</p>
  
  <p>My (failed) attempt looks like this, three files:</p>
  
  <p>beachregister:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;OO Method test&lt;/title&gt;
      &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          $(document).ready(function() {
              setInterval(function() {
                  $("#BaiadoSancho").load();
              }, 60000);
          });
  
          $(document).ready(function() {
              setInterval(function() {
                  $("#GraceBay").load();
              }, 60000);
          });
  
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;?php
      include 'Baiadosancho.php';
      include 'Gracebay.php';
  
      $baia = new Baiadosancho;
      $baia-&gt;setTemp();
  
      $grace = new Gracebay;
      $grace-&gt;setTemp();
  
      // .... lots of other beaches
      ?&gt;
  
      &lt;div id = "BaiadoSancho"&gt;
          &lt;?php $baia-&gt;setTemp(); ?&gt;
      &lt;/div&gt;
  
      &lt;div id = "GraceBay"&gt;
          &lt;?php $grace-&gt;setTemp() ?&gt;
      &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Baiadosancho.php
      
  
  <pre><code>class Baiadosancho{
  private $temp;
  
  public function getTemp() {
      return $this-&gt;temp;
  }
  
  public function setTemp() {
  //        $json = file_get_contents('urltogettemperature');
  //        $arrayDecodedFromJSON = json_decode($json, true);
  //        ...
  //        $this-&gt;temp = $arrayDecodedFromJSON['temp'];
  }
  
  }
  </code></pre>
  
  <p>Gracebay.php
      
  
  <pre><code>class Gracebay {
  
  private $temp;
  
  public function getTemp() {
      return $this-&gt;temp;
  }
  
  public function setTemp() {
  //        $json = file_get_contents('sampl/temperature');
  //        $arrayDecodedFromJSON = json_decode($json, true);
  //        ...
  //        $this-&gt;temp = $arrayDecodedFromJSON['temp'];
  
  
  }
  
  }
  </code></pre>
  
  <p>..I have also considered other means like the ones below, are they favorable you think?</p>
  
  <p>GearMan, Parallel cURL execution in PHP, EvPeriodic and iron.io</p>