 <p>You can use jQuery for that. 1. Download jQuery: <a href="http://jquery.com/download/" rel="nofollow">http://jquery.com/download/</a> 2. Include the script you downloaded into your webpage:</p> <pre><code>&lt;script src='/path/to/downloaded/jquery'&gt;&lt;/script&gt; </code></pre> <ol start="3"> <li>Then it all depends on when you want your ajax to be executed. Let's assume you have a link that should load your data. Then you can do it like that:</li> </ol> <p>HTML code</p> <pre><code>&lt;a id='#mylink' data-id='123&gt;My link&lt;/a&gt; </code></pre> <p>Javascript code</p> <pre><code>&lt;script&gt; $('#mylink').on('click', function() { $.get('different.php', {'id': $(this).attr('data-id')}, function(resonse) { // response variable contains your JSON from different.php script, so write here you JavaScript code that uses it }); }); &lt;/script&gt; </code></pre> <p>Hope it helps.</p>