title: Why doesn't setting document.domain work to allow AJAX requests to a parent domain?
body: <p>I have two files, domain.com/test2.php:</p>
  
  <pre><code>&lt;div id="testDiv"&gt;&lt;/div&gt;
  
  &lt;script src="http://domain.com/packages/jquery.js"&gt;&lt;/script&gt;
  &lt;script&gt;$("#testDiv").load("http://domain.com/test3.php", {var1:1, var2:2});&lt;/script&gt;
  </code></pre>
  
  <p>and domain.com/test3.php:</p>
  
  <pre><code>&lt;b&gt;var1: &lt;?php echo $var1; ?&gt; , var2: &lt;?php echo $var2; ?&gt;&lt;/b&gt;
  </code></pre>
  
  <p>In this case domain.com/test2.php outputs
      <b><code>var1: 1 , var2: 2</code></b> as one would expect, but let's now say I want to make a test2.php in a subdomain. To stop problems with cross-domain scripting, I would add this extra line to the start of sub.domain.com/test2.php:</p>
  
  <pre><code>&lt;script&gt;document.domain = "domain.com";&lt;/script&gt;
  </code></pre>
  
  <p>This extra line stops the cross-domain error from showing up, but now the file no longer outputs <b><code>var1: 1 , var2: 2</code></b>. Why is this and how can I fix this?</p>