Using this code
var sw = window.screen.width;
$.post("http://www.example.com/track.php", {result: sw
}, "html");
and $_SERVER[‘result’]; in the server I’m trying to get the sreen width but it does not work. It is something wrong with the “result”. I’m new in Javascript and jQuery…
$_SERVERcontains server variables, that is, things like the operating system, the referrer URL, paths to various folders on the server.What you’re looking for instead is either the
$_POSTarray, the$_GETarray, or the$_REQUESTarray. I might be stating the obvious here, but here’s what they contain:$_POSTcontains a list of all variables POSTed to the script.$_GETcontains a list of all variables in the query string (eg:someScript.php?x=1&y=2)$_REQUESTcontains a merge of$_POST,$_GETand$_COOKIE(usually in that order). I don’t recommend using this: you should know the methods you’re using to get variables into your script and use that array specifically.In your case, you need to take a look at the
$_POSTarray. It’s always handy to run this once:This will show you everything posted to that page.