title: Call PHP Function from Smarty with AJAX with no user action
body: <p>I am hitting a lot of different sites to get a list of information and I want to display this information as I get it. Right now I am using a Smarty Template and what I would like to do is:</p>
  
  <p>Pseudo code:</p>
  
  <pre><code>{foreach $page} 
    $smarty_var = use AJAX to call a PHP function
    Render out a new table row on the fly w/ the newly assigned var   
    &lt;tr&gt;&lt;td&gt;{$smarty_var}&lt;/td&gt;&lt;/tr&gt;
  {/foreach}
  </code></pre>
  
  <p>I don't know much about AJAX, I used it a long time ago, and it was similar to this, but not quite, there was user action taken. No I don't have a JS Framework in place. Am I way off here on how this should go? Basically I want to display a table row as data comes available, each table row will be a request to get the data from another site.</p>
  
  <p>Sure, I will tell you about what I am trying to do: <a href="http://bookscouter.com/prices.php?isbn=0132184745+&amp;x=19&amp;y=6" rel="nofollow noreferrer">http://bookscouter.com/prices.php?isbn=0132184745+&amp;x=19&amp;y=6</a>
  If you click on the 'Click to view prices from all 43 links' at the bottom on that page you will see. I am using cURL to get all the pages I want a price from. Then for each page I want to get the price. So each page is gonna fire off a function that runs some fun code like this:</p>
  
  <pre><code>function parseTBDOTpageNew($page, $isbn)
  {
      $first_cut = preg_split('/&lt;table[^&gt;]*&gt;/', $page);
      $second_cut = preg_split('/&lt;td[^&gt;]*&gt;/', $first_cut[2]);
      if(strstr($second_cut[4], "not currently buying this book") == true)
      {
          return "\$0.00";
      }
      $third_cut = preg_split('/&lt;b[^&gt;]*&gt;/', $second_cut[9]);
      $last_cut = preg_split('/&lt;/', $third_cut[3]);
      return $last_cut[0];
  }
  </code></pre>
  
  <p>This function is called from another function which puts the price returned from the function above, the name of the company, and a link in an array to be added to another bigger array that is sent to smarty. Instead of doing that, I just want to get the first array that is returned with individual information and add the values into a table row on the fly.</p>
  
  <p>I will take your advice on Jquery, what I have started is an onload function that receives the $pages to be parsed, and I was just in the middle of writing: foreach page get the info and spit some html w/ the info on the page. </p>
  
  <p>Also the function that calls the function to get the price is in a php file, so I need the request to hit a function within a php file and NOT just call file.php?param1=foo, I need to it to actually hit the function in the file. I have Jquery in place, now just trying to figure it out and get it to do what I need, ugh. I am searching, any help would be appreciated.</p>