How to tell a page to load a JS function based on variables being sent
<p>I have a function which loads some content when executed...</p>

<p>IE...</p>

<pre><code>function load_product(product_id) {

$.ajax({
  type: 'GET',
  url: 'product_image.php',
  data: 'product_id='+product_id+'',
  success: function(data) {
        $('#product_image').html(data);
  }
});
}
</code></pre>

<p>That works great. But say I want to create a link to a page, so that then something triggers to load up the dynamic content?</p>

<p>IE I link to a page, say </p>

<pre><code>www.blah.com/?product=1 
</code></pre>

<p>and a few 'divs' on the page that load up different things dynamically for product #1.</p>

<p>The way I currently do it is by doing something:</p>

<pre><code>&lt;?php

  if($_REQUEST['product_id']) {

    echo '

     &lt;script type="text/javascript"&gt;

        $(document).ready(function(){

           load_product(' . $_REQUEST['product_id'] . ');

        });

     &lt;/script&gt;

      ';

  }
</code></pre>

<p>And I put that somewhere on the new page being loaded. It works. But is there a better way?</p>
