title: Send ONLY $_POST variables to PHP using AJAX, without HTML response
body: <p>I'm trying to send only <code>$_POST</code>'s variables (vars from the <code>$_POST</code> array) into PHP file using AJAX call. I don't want to say on success: <code>alert('ok, it's fine')</code> or <code>$('blah').text('done it!')</code>. I'd like to post variables into <code>$_POST</code> table of the PHP file and nothing more. Ok, let's look into my files below:</p>
  
  <p><code>ajax.php</code></p>
  
  <pre><code>echo '&lt;script type="text/javascript" src="http://'.$_SERVER["HTTP_HOST"].'/media/system/js/jquery_check.js"&gt;&lt;/script&gt;';
  echo '&lt;script type="text/javascript" src="http://'.$_SERVER["HTTP_HOST"].'/ajax.js"&gt;&lt;/script&gt;';
  </code></pre>
  
  <p><br /></p>
  
  <p><code>ajax.js</code></p>
  
  <pre><code>jQuery(document).ready(function () {
      jQuery.ajax({
      url: "ajax.php",
      type: "POST",
      data: { id:12345,whatever:'blahblah' },
      success: function (data) {
          alert(data);
      }
      });
  });
  </code></pre>
  
  <p>So, when I run <code>ajax.php</code> with this example, I get alert info:</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://localhost.dev/media/system/js/jquery_check.js"&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://localhost.dev/ajax.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>If I put e.g. <code>jQuery('#photoid').text(data);</code> in the success function and add <code>&lt;div id="photoid"&gt;&lt;/div&gt;</code> in the PHP file, and additionally <code>var_dump($_POST)</code>, I'll get this HTML response on the screen (and as an alert info as well):</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://localhost.dev/media/system/js/jquery_check.js"&gt;&lt;/script&gt;&lt;script type="text/javascript" src="http://localhost.dev/ajax.js"&gt;&lt;/script&gt;array(2) { ["id"]=&gt; string(5) "12345" ["whatever"]=&gt; string(8) "blahblah" } &lt;div id="photoid"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>What I want to make is a call that will make my PHP file have only post data stuff sent (<code>id</code> and <code>whatever</code>) and written into <code>$_POST</code> superglobal array in the PHP file. So I don't need these script stuff etc. because in my real PHP script I don't need to have any HTML data displayed on the site, only POST data received by PHP file. Is that possible? </p>
  
  <p>Anyway the <code>div</code> code is needless for me, but as I see it's needed to exist in order to have possibility to read any POST data. Also the POST data are being written into <code>array(1)</code> or <code>array(2)</code> instead of the standard <code>$_POST</code> array so I can only read data by using <code>foreach</code> loop (<code>$_POST['id']</code> shows error with no such index available).</p>
  
  <p>I'm using XAMPP locally if it's important. But this should work locally too.</p>
  
  <p>Any ideas?</p>