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条)

报告相同问题?

悬赏问题

  • ¥15 脱敏项目合作,ner需求合作
  • ¥15 脱敏项目合作,ner需求合作
  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密