I am using AJAX to send some variables to a PHP form that will process them and put them into session variables. In the code below, I am trying to get data from two POST variables.
If I leave both as they are, none will work. If I comment out one, the other will work, and vice versa. I'm not sure what I'm doing wrong here.
Here is the AJAX that sends data to the PHP page to be processed:
$.ajax({
type: 'POST',
async: false,
data:
{
from_date: from_date,
job_no: job_no,
},
url: 'pnf_post.php', //send variables to this page to be processed
success: function(data){
oTable2.fnReloadAjax('FE_resolved_pnfs.php'); //reload datatables
},
error: function(){
console.log(data);
alert('Error');
}
});
Here is the code that processes the AJAX data:
session_start();
if(isset($_POST['job_no']))
{
$_SESSION['Job_Num'] = $_POST['job_no'];
$_SESSION['Search_By_Date'] = "NO";
}
if(isset($_POST['from_date']))
{
$_SESSION['From_Date'] = $_POST['from_date'];
$_SESSION['Search_By_Date'] = "YES";
}
Any help would be greatly appreciated