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 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办