 <p>Sounds like you are looking for the <a href="http://en.wikipedia.org/wiki/HTTP_referrer" rel="nofollow"><strong>HTTP Referrer</strong></a>. You can get it via <a href="http://php.net/manual/en/reserved.variables.server.php" rel="nofollow"><code>$_SERVER['HTTP_REFERER']</code></a>.</p> <p>But note that this can be changed by the user to something else, so you actually cannot rely on that.</p> <hr> <p>Maybe it is better to send the current URL via the Ajax call, along with the ID:</p> <pre><code>$('#file').load('fun2.php?id='+ Math.random() +'&amp;parent=' + encodeURIComponent(window.location)); </code></pre> <p>But again, if one really wants to, he can change this too. So you can never 100% trust that one request is really coming from a certain page.</p> <p>Reference: <a href="https://developer.mozilla.org/en/DOM/window.location" rel="nofollow"><code>window.location</code></a>, <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent" rel="nofollow"><code>encodeURIComponent</code></a></p>