小编Geo*_*ssi的帖子

从OpenLayers JavaScript接收PHP的POST请求

我在PHP中接收POST请求时遇到问题.我正在使用JavaScript将数据发送到带有POST请求的PHP页面.JavaScript来自OpenLayers.js,发送请求的部分如下所示:

var postrequest = OpenLayers.Request.POST({
        url: "http://localhost/index.php",
        data: "success",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        }
    });
Run Code Online (Sandbox Code Playgroud)

在PHP中,我正在使用此代码来查看,我得到了什么:

<?php
    print_r($_POST);
?>
Run Code Online (Sandbox Code Playgroud)

这是发生的事情:

  1. index.php接收POST请求.
  2. FireBug还会通知POST参数包含已发送的成功.
  3. 的print_r($ _ POST); 在index.php中只提供了这个:array()并且在来自JavaScript的POST请求后没有改变.

所以发送和接收数据,但我的PHP代码不知道它,或者我没有使用正确的PHP函数.

任何建议,在哪里寻找,以及尝试什么?

javascript php post openlayers

2
推荐指数
1
解决办法
2614
查看次数

标签 统计

javascript ×1

openlayers ×1

php ×1

post ×1