This is really basic. All I want to do is measure the html width of a browser window, and pass that data to a PHP script so that I can adjust what information is passed to the site.
I've got the HTML width part down. I'm just having trouble passing the Javascript/jQuery variable to the PHP script using AJAX.
Here's the Javascript/jQuery. It is written in PHP so that I can use the include()
function later.
echo
'<script>
htmlWidth = $("html").width();
$.ajax({
type: "POST",
url: "mobileView.php",
data:{ width: htmlWidth }
})
</script>';
And here's the PHP:
$width = $_POST['width'];
function mobileView(){
if ($width < 950){
return true;
} else{
return false;
}
}
mobileView();