title: Ajax request always fails
body: <p>I'm trying to send variables of username and password to a PHP file from a
  JS file, but the ajax request always fails (prints fail), no idea why.</p>
  
  <p>JS file:</p>
  
  <pre><code>&lt;script&gt;
      var imported = document.createElement('script');
      imported.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js';
      document.querySelector('head').appendChild(imported);
  
      function collect() {
          var user = "joe";
          var pass = "123";
          $.ajax({
              type:'POST',
              url: 'myphp.php',
              data: {'username': user, 'password': pass},
              success: function(){
                  alert("success!");
              },
              error: function(){
                  alert("fail");
              }
          });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>PHP file:</p>
  
  <pre><code>&lt;?php
  $myval = $_POST['username'];
  echo($myval);
  ?&gt;
  </code></pre>