Okay so I'm trying to follow this tutorial but instead of storing it in a database I'm gonna store it somewhere else.
One problem though I have no clue how to append PHP variables with jQuery to the body!
Here is index.php
<html>
<head>
<title>Store Your Browser Resolution!</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<button id="btn-POST">CLICK</button>
</body>
Here is Main.js
$(document).ready(function(){
$("#btn-POST").click(function(){
$.ajax({
type: 'POST',
url: '/index.php',
data: {
width : $(window).width(),
height : $(window).height(),
screen_width : screen.width,
screen_height: screen.height
},
success: function( data )
{
console.log('SUCCESS!');
$("body").append($('<?php $width = $_POST["width"]; $height = $_POST["height"]; $screen_width = $_POST["screen_width"]; $screen_height = $_POST["screen_height"]; ?>'));
$("body").delay(800).append($('<?php echo ?>'))
}
});
});
console.log('Test!');
});
Any help would be appreciated :)
-Alex
index.phpshould insert the POST variables into the result that it returns.