I tried to post a form content to a remote hosted PHP page, this is my code:
$.ajax({
type: "POST",
url: "http://url/page.php",
data: formstring, // formstring=form.serialze();
dataType: "text",
success: function (data) { alert(data);},
error: function () {}
});
I started my PHP file with:
<?php
header('Access-Control-Allow-Origin: *');
print("hi");
die();
I see in Firebug only OPTIONS request:
Response Headers:
Access-Control-Allow-Orig... *
Connection Keep-Alive
Content-Encoding gzip
Content-Length 22
Content-Type text/html
Date Tue, 25 Feb 2014 11:14:22 GMT
Keep-Alive timeout=15, max=99
Server Apache
Vary Accept-Encoding
X-Powered-By PHP/5.3.3-7+squeeze18
Request Headers:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,fr;q=0.7,en;q=0.3
Access-Control-Request-He... x-requested-with
Access-Control-Request-Me... POST
Cache-Control no-cache
Connection keep-alive
Host www.domain.tld
Origin http://212.xxx.252.xxx
Pragma no-cache
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0