CORS stops me from developing on localhost - can't find a 'cure'
I am using jQuery to run a php script on my LOCAL ONLY Apache server under xampp 1.8.3, PHP 5.5.0 I have added the following to my httpd.conf file at the end. <Directory />
Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Headers "Content-Type" Header set Access-Control-Allow-Methods "GET, PUT, OPTIONS, DELETE, POST"
</Directory> <Directory "C:/xampp/htdocs/yankeebeds">
AllowOverride All Options None Require all granted
</Directory> And, I absolutely cannot get this PHP file to execute - always get null back for data: print_r('
'); print_r($_POST); print_r('');
echo('pageChanger.php says: postedParms=' . $_POST['postedParms']); ?> The HTML is: <a onclick="runOnServer('pageChanger.php','HOME.html');"> The jQuery call is: function runOnServer(whatToRun, parameters) {
alert('at runOnServer with ==>' + whatToRun + ' and ' + parameters); var posting = $.post(whatToRun, { postedParms: parameters }); posting.done(function(data) { //var data1 = jQuery.parseJSON(data); alert("What we got back:" + data); });
}
I am using jQuery to run a php script on my LOCAL ONLY Apache server under xampp 1.8.3, PHP 5.5.0
I have added the following to my httpd.conf file at the end.
<Directory />
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Content-Type"
Header set Access-Control-Allow-Methods "GET, PUT, OPTIONS, DELETE, POST"
</Directory>
<Directory "C:/xampp/htdocs/yankeebeds">
AllowOverride All
Options None
Require all granted
</Directory>
And, I absolutely cannot get this PHP file to execute - always get null back for data:
<?php // pageChanger.php
@session_start();
print_r('<pre>'); print_r($_POST); print_r('</pre>');
echo('pageChanger.php says: postedParms=' . $_POST['postedParms']);
?>
The HTML is: <a onclick="runOnServer('pageChanger.php','HOME.html');">
The jQuery call is:
function runOnServer(whatToRun, parameters) {
alert('at runOnServer with ==>' + whatToRun + ' and ' + parameters);
var posting = $.post(whatToRun, { postedParms: parameters });
posting.done(function(data) {
//var data1 = jQuery.parseJSON(data);
alert("What we got back:" + data);
});
}