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

报告相同问题?

悬赏问题

  • ¥60 Qcustomplot绘制实时动态曲线
  • ¥20 运用matlab画x-y图
  • ¥15 用idea运行项目,运行tomcat报错:断言失败
  • ¥15 Sqlserver查询链接服务器数据问题
  • ¥15 Bibtex4Word 引用中文文献
  • ¥20 用opencv c/c++ 转换成灰度图,然后做一下直方图均衡,输出mp4文件
  • ¥20 matlab中的双层数值积分
  • ¥50 服务器打印水晶报表问题
  • ¥30 gradle环境下javafx项目如何使用druid连接池
  • ¥15 服务器打印水晶报表问题