title: AJAX post to external url
body: <p>I am trying to post data with ajax to an external url with the following code:</p>
  
  <pre><code>$(document).ready(function(){
      $('.submit_button').click(function() {
          $.ajax({
                  type : 'POST',
                  url : 'http://site.com/post.php',
                  dataType : 'text',
                  data: $("#infoForm").serialize()
          }).done(function(results) {
                      alert(results);
          });
          event.preventDefault();
      });
  });
  </code></pre>
  
  <p>But I am getting the following error:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://site.com/post.php" rel="nofollow">http://site.com/post.php</a>. Origin null is not allowed by Access-Control-Allow-Origin. </p>
  </blockquote>
  
  <p>I have also added the the following line to the htaccess file on my server</p>
  
  <pre><code>Header set Access-Control-Allow-Origin *
  </code></pre>
  
  <p>Would anyone be able to tell me what I am doing wrong and how I can post data to an external url? </p>