title: How to make cross domain request
body: <p>As you know, the security of the web browser disallows making of cross domain requests. I read a book which says that you should use XMLHTTPRequest only if you can put the files on the server (means put the page you will load to the same requested domain). If you can't - you should search for an alternative.</p>
  
  <p><strong>My questions are</strong>:</p>
  
  <ol>
  <li>What is the cross domain alternative to XMLHTTPRequest?</li>
  <li><strong><em>What about WebSockets</em></strong>? Does this technology allow cross domain request?</li>
  </ol>
  
  <p><strong>EDIT:</strong>
  It still isn't clear to me...</p>
  
  <p>For example, I pull my page from <em>www.domain1.com</em> and I need to request javascript from <em>www.domain2.com</em>. So the pulled page should include something like:</p>
  
  <pre><code>&lt;script src="www.domain2.com/script.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>to avoid cross domain restrictions.</p>
  
  <p>And I can use JSONP, and request will look like:
  <em><a href="http://ww.domain1.com/?callback=someFunction.js" rel="noreferrer">http://ww.domain1.com/?callback=someFunction.js</a></em></p>
  
  <p><strong>But: isn't it the same? I just pull js from another domain! Does it avoid cross domain restrictions?</strong></p>