As the title describes it, I cannot get the value from my JQuery variable into a PHP one.
My JQuery code is like this:
$(document).ready(function() {
var mbscr = 0;
function checkSize() {
if ($("#orientation").css("width") == "200px") {
var mbscr = 1
} else {
var mbscr = 2
}
$.ajax({
type:"POST",
url: './a/cmn.arr.php',
data: { mbscr : mbscr },
cache: false,
success: function(data) {
console.log(data);
}
});
return false;
};
checkSize(mbscr);
$(window).resize(checkSize);
});
The PHP one is:
if(isset($_POST['mbscr']) && !empty($_POST['mbscr'])) {
$_get_mbscr = $_POST['mbscr'];
}
var_dump($_get_mbscr);
If I use alert() instead of console.log(), the JQuery parts does its job, it alerts me what it should. My problem is I always get a null value for var_dump(), even when I do var_dump($_POST['mbscr']).
Any help will be appreciated, thank you.