Who can help me?
I have a problem with getting the parameters (out of an array) into PHP $_POST. The parameters which has been send by $ajax are well filled. When I try to get grab the whole array into the PHP script, there is no $_POST or $_GET available. What do I wrong. I have tried it also with the single parameters, which fail also. I tried all possible manners to grap the parameters ($_GET as well as $_POST). What do I wrong?
for example the input has been defined as below and work well
-- for example the input has been defined as below and work well
<div class="site input"> <i class="icon-pend icon calendar"></i>
<input name="fromdate" type="text" data-datepicker="true" value="<?php if($_POST['fromdate'] <> ""){ echo $_POST['fromdate'];} else{echo $_GET['fromdate'];} ?>" placeholder="<?php echo Lang::$word->FROM;?>" id="fromdate" data-bind="<?php if($_POST['fromdate'] <> ""){ echo $_POST['fromdate'];} else{echo $_GET['fromdate'];} ?>"></div>
-- The post looks like this below
function createVerzuimServiceReport1()
{
var pg='<?php echo $_GET['pg'] ?>';
var ipp='<?php echo $_GET['ipp'] ?>';
var fromdate_submit=$('input[name="fromdate_submit"]').val();
if(fromdate_submit=='') {
fromdate_submit='<?php echo $_GET['fromdate_submit'] ?>'; }
var enddate_submit=$('input[name="enddate_submit"]').val();
if(enddate_submit=='') {
enddate_submit='<?php echo $_GET['enddate_submit'] ?>'; }
var date = new Date(Date.parse($('#fromdate').val())),
d = ("0" + date.getDate()).slice(-2),
m = ("0" + (date.getMonth() + 1)).slice(-2),
y = date.getFullYear(),
fDate = y + '-' + m + '-' + d;
var date = new Date(Date.parse($('#enddate').val())),
d = ("0" + date.getDate()).slice(-2),
m = ("0" + (date.getMonth() + 1)).slice(-2),
y = date.getFullYear(),
lDate = y + '-' + m + '-' + d;
var postData = { };
postData.action = "postData";
postData.createVerzuimServiceReport1 = "createVerzuimServiceReport1";
postData.fromdate_submit = fDate;
postData.enddate_submit = lDate;
postData.studentsearchfield = $('#filter').val();
$.ajax({
type: "post",
url: "../plugins/registereddayvr/controller_verzuim_tot.php",
data: postData,
dataType: "json",
success: function(data) {
alert(postData.action + ' ' + postData.createVerzuimServiceReport1 + ' ' + postData.fromdate_submit + ' ' + postData.enddate_submit + ' ' + postData.studentsearchfield);
alert(postData.action + ' ' + postData.createVerzuimServiceReport1 + ' ' + postData.fromdate_submit + ' ' + postData.enddate_submit + ' ' + postData.studentsearchfield);
window.open("../plugins/registereddayvr/controller_verzuim_tot.php", "MsgWindow", "width=800, height=900");
if(data.fout)
alert('FOUT BERICHT: ' + data.bericht);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
};
-- The php looks like this
if(isset($_POST['action']) && $_POST['action'] == "postData") { //if(isset($_GET['action']) && $_GET['action']== "postData")
$vals = array(
'action' => $action,
'createVerzuimServiceReport1' => $createVerzuimServiceReport1,
'fromdate_submit' => $fromdate_submit,
'enddate_submit' => $enddate_submit,
'studentsearchfield' => $studentsearchfield
);
// JSON encode er zijn params gevonden verstuur naar $.ajax success.
echo 'resultaat is: '.json_encode($vals);
exit; // zeker weten dat er niets anders is
}
else { // zo is er toegang tot de fout bericht in jQuery
echo json_encode(array('fout' => TRUE, 'bericht' => 'Een probleem is ontstaan! Fout is: Er zijn geen parameters ontvangen in controller_verzuim_tot.php...', 'get' => $_GET, 'post' => $_POST,));
exit;
}
I have checked all posted answers on stackoverflow and have read a lot of messages regarding this subject and I have followed up a few answers but the sender ($_POST) is not present. What do I wrong? Thanks for your answers.