dousao8152 2010-01-16 13:33
浏览 56
已采纳

使用jQuery发布屏幕宽度

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...

http://api.jquery.com/jQuery.post/

  • 写回答

4条回答 默认 最新

  • dss524049 2010-01-16 13:43
    关注

    $_SERVER contains 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 $_POST array, the $_GET array, or the $_REQUEST array. I might be stating the obvious here, but here's what they contain:

    • $_POST contains a list of all variables POSTed to the script.
    • $_GET contains a list of all variables in the query string (eg: someScript.php?x=1&y=2)
    • $_REQUEST contains a merge of $_POST, $_GET and $_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 $_POST array. It's always handy to run this once:

    print_r($_POST);
    

    This will show you everything posted to that page.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?