I was working on a simple link that would initiate an ajax call. This worked as expected until our Ubuntu server got decommissioned; we have a new, 'identical' server. The problem occurs on the server side, when I examine what is in POST. Expected echo of $_POST["scan_date"] is: 2012-11-26
Actual echo is: 2012-11-26scan_date=2012-11-26
And this is the actual echo in the PHP code below. The client side alert gives this: 2012-11-26 and that is what i expect. So, it appears that something is happening on the server side. I expect the echo to be "2012-11-26" and not "2012-11-26scan_date=2012-11-26"
I can't figure out why the POST data is getting munged up like that.
PHP:
$date = isset($_POST["scan_date"]) ? $_POST["scan_date"] : date("Y-m-d");
echo $date; //produces 2012-11-26scan_date=2012-11-26 which is bad
JQuery:
var val = $(this).attr('value');
dateSelected = val.replace(/facterOption-/g, "");
dateSelected = $.trim(dateSelected);
alert(dateSelected); //alerts 2012-11-26 which is good
$.ajax({
type: "POST",
dataType: 'json',
url: 'https://someurl',
data: {
scan_date: dateSelected
}
})
UPDATE: We have tried command line curl calls that were completely outside of the code framework for this PHP project, and the same result is being noticed. So maybe Apache has something to do with this.
Additionally, we discovered that adding a second POST parameter and value took care of this.