Getting absolute URL requested by XMLHttpRequest?
<p>Assuming <code>http://example.com/js/script.js</code> fires an AJAX request against some relative URL, how do I get the absolute URL that ended up being requested?</p>

<p>For example, if I request <code>image.png</code> from <code>http://example.com/js/script.js</code> I'd expect to get back <code>http://example.com/js/image.png</code>. If, however, I requested <code>/image.png</code> from the same URL I'd expect to get back <code>http://example.com/image.png</code>.</p>

<p>This question is tricky for two reasons:</p>

<ol>
<li><strike>I don't believe it's possible to get a script's URL from inside it.</strike> <strong>UPDATE</strong>: I incorrectly assumed that AJAX requests are issued relative to the script location. It turns out that they are issued relative to <code>location.href</code>. This simplifies the situation.</li>
<li>I don't believe that <code>XMLHttpRequest</code> exposes the request URL, not to mention its absolute form.</li>
</ol>

<p>Any ideas?</p>
