title: Get hostname in JQuery
body: <p>I've got a JQuery function using getJSON to bring some userifo. It's like that:</p>
  
  <pre><code>$.getJSON("http://server.com/?apirequested=userinfo", function(data){
     ...
     ...
  });
  </code></pre>
  
  <p>This works fine, but I'm trying to change it to use same code for several servers using relatives url's.</p>
  
  <p>I'm trying several things like:</p>
  
  <pre><code>$.getJSON($(location).attr('hostname')+"/?apirequested=userinfo" ...
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$.getJSON($(location).attr('protocol')+$(location).attr('hostname')+"/?apirequested=userinfo",
  </code></pre>
  
  <p>or    </p>
  
  <pre><code>$.getJSON(location.hostame+"/?apirequested=userinfo" ...
  </code></pre>
  
  <p>But it does not work. What am I doing wrong?</p>
  
  <p>Any suggestions?</p>
  
  <p>Thanks in advance for your time.</p>