I'm sure there is a simple answer to this stupid problem but I have searched high and low and can not figure out why this wont work.
$tutorid = $_GET['userid'];
var_dump($tutorid);
//populate user tutoring subjects
if( isset($_POST['a'])) {
$currentsubjects = get_current_user_subjects( $tutorid );
unset($_POST['a']);
echo json_encode($currentsubjects); return;
}
I have a simple AJAX
function that sets $_POST['a']
equal to something. The var_dump($tutorid)
properly displays the id from the url. However the $tutorid
in the get_current_user_subjects
is sending NULL
.
If I try a var_dump
like this to check $tutorid
$tutorid = $_GET['userid'];
//populate user tutoring subjects
if( isset($_POST['a'])) {
echo json_encode($tutorid); return;
// $currentsubjects = get_current_user_subjects( $tutorid );
// unset($_POST['a']);
// echo json_encode($currentsubjects); return;
}
Then I get NULL
. If I hard code in a tutorid in the get_current_user_subjects( $tutorid )
(like add in 15 or something) the function returns data to console.log like expected but using the variable $tutorid
stops it completely. I can't figure out why this is happening! Someone please enlighten me.
Here is the AJAX just incase. It works find on other pages so I am assuming the issue is with $_GET
$.ajax({
url: 'profile.php',
method: 'post',
data: "a=true",
dataType: 'json',
success: function (x) {
console.log(x);
},
error: function(a, b, c) {
console.log(a);
console.log(b);
console.log(c);
}