For some reason the post value isn't being shown even tho in var_dump it shows that it's there.

You can see that the $_POST["ajaxMonth"] has a string value of "2" in the first image however when I echo it, it has nothing as show in the second image. Here is my php
$ajaxMonth = $_POST["ajaxMonth"];
$ajaxYear = $_POST["ajaxYear"];

var_dump($_POST);

echo '<div class="day">'. $ajaxMonth .'</div>';
$ajaxMonth = $_POST["ajaxMonth"];
$ajaxYear = $_POST["ajaxYear"];

var_dump($_POST);

echo '<div class="day">'. $ajaxMonth .'</div>';
Here is my Ajax
// Show the days with events if there is events in that certain day
$(".days").load('model/showDayCalendarEvents.php', {ajaxPrevLastDayNum:prevLastDayNum, ajaxLastDayWeekday:lastDayWeekday, ajaxLastDayWeekDate:lastDayWeekDate, ajaxFirstDayNumber:firstDayNumber, $ajaxMonth:month, $ajaxYear:year});
// Show the days with events if there is events in that certain day
$(".days").load('model/showDayCalendarEvents.php', {ajaxPrevLastDayNum:prevLastDayNum, ajaxLastDayWeekday:lastDayWeekday, ajaxLastDayWeekDate:lastDayWeekDate, ajaxFirstDayNumber:firstDayNumber, $ajaxMonth:month, $ajaxYear:year});
No description
No description
16 Replies
Jochem
Jochem7mo ago
you've got a superfluous $ in the variable name I'm guessing your name attribute in your input tag is something like name="$ajaxYear" or something?
kingtigerknight
kingtigerknight7mo ago
no, the the $_POST["ajaxMonth"] is from the ajax itself.
Jochem
Jochem7mo ago
in the screenshot, the key is called "$ajaxMonth"
kingtigerknight
kingtigerknight7mo ago
yes, thats from the ajax $ajaxMonth:month
Jochem
Jochem7mo ago
I'm saying if your var_dump shows $ajaxMonth as a key, and you're accessing the key ajaxMonth on $_POST, those are not the same thing try $ajaxMonth = $_POST['$ajaxMonth'];
kingtigerknight
kingtigerknight7mo ago
dosen't work
Jochem
Jochem7mo ago
how are you submitting your POST?
kingtigerknight
kingtigerknight7mo ago
by ajax
Jochem
Jochem7mo ago
can you share how you populate that?
kingtigerknight
kingtigerknight7mo ago
like this one?
$(".days").load('model/showDayCalendarEvents.php', {ajaxPrevLastDayNum:prevLastDayNum, ajaxLastDayWeekday:lastDayWeekday, ajaxLastDayWeekDate:lastDayWeekDate, ajaxFirstDayNumber:firstDayNumber, $ajaxMonth:month, $ajaxYear:year});
$(".days").load('model/showDayCalendarEvents.php', {ajaxPrevLastDayNum:prevLastDayNum, ajaxLastDayWeekday:lastDayWeekday, ajaxLastDayWeekDate:lastDayWeekDate, ajaxFirstDayNumber:firstDayNumber, $ajaxMonth:month, $ajaxYear:year});
There was another one that worked I made. The values were shown there, however I can't use this one since there for different things
$('.events').load('model/loadCalendarEvents.php', {ajaxDay:Number(date), $ajaxMonth:month, $ajaxYear:year});
$('.events').load('model/loadCalendarEvents.php', {ajaxDay:Number(date), $ajaxMonth:month, $ajaxYear:year});
Jochem
Jochem7mo ago
why is the $ there on ajaxMonth in this snippet?
kingtigerknight
kingtigerknight7mo ago
thats what my teacher put as for the name.
Jochem
Jochem7mo ago
try removing the $ sign there?
kingtigerknight
kingtigerknight7mo ago
dosen't work. I know that it works tho because in the 2nd snippet it's the same name but it works.
Jochem
Jochem7mo ago
then I don't know. The most obvious thing here is that the key in the vardump ($ajaxMonth) doesn't match the key you're accessing (ajaxMonth). If that's not it, I'm blaming gremlins.
Want results from more Discord servers?
Add your server