I am trying to post data with ajax to an external url with the following 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();
});
});
But I am getting the following error:
XMLHttpRequest cannot load http://site.com/post.php. Origin null is not allowed by Access-Control-Allow-Origin.
I have also added the the following line to the htaccess file on my server
Header set Access-Control-Allow-Origin *
Would anyone be able to tell me what I am doing wrong and how I can post data to an external url?