JavaScript URL without localhost
<p>I am new to JavaScript and I want to write JavaScript scripts which will works without "localhost" and port etc.</p>

<p>Here is the example of my code:</p>

<pre><code>jQuery.ajax({
    type: "GET",
    url: "http://localhost:8081/trainer/testToUser",
    dataType: "json",
    contentType: "application/json; charset=utf-8",
</code></pre>

<p>And I want something like this:</p>

<pre><code>jQuery.ajax({
    type: "GET",
    url: "trainer/testToUser",
    dataType: "json",
    contentType: "application/json; charset=utf-8",
</code></pre>

<p>(This variant does not work)</p>

<p>Which will work without with any port for example. I read about "window.location", should I use something like this?</p>