Post方法接收值为无效值

时间:2016-02-15 02:18:16

标签: javascript php jquery

通过$ .post方法我向PHP服务器提交一个ID号。在谷歌浏览器中可见,我看到值已正确发送,但在PHP服务器调试中,我看到收到的值带有未知的额外值。

PHP:

$rrn = str_replace('"',"",$_POST['rrn']); $sql = "select *From sh_av_spidcard where rrn='{$rrn}' limit 1";

发送值为10224440075,但添加了两个未知值\u000这是什么?以及如何解决它?

在浏览器控制台上调试:

enter image description here enter image description here

编辑:

JavaScript的:

  input  = input.replace(/^\s*|\s*$/g, "");
  input  = input.replace(/^\s*/g, "");
  input  = input.replace(/\s*$/g, "");

PHP:

$aChr = array(
        "\u0000", "\u0001", "\u0002", "\u0003", "\u0004",
        "\u0005", "\u0006", "\u0007", "\u0008", "\u0009", "\u000A",
        "\u000B", "\u000C", "\u000D", "\u000E", "\u000F", "\u0010", "\u0011",
        "\u0012", "\u0013", "\u0014", "\u0015", "\u0016", "\u0017", "\u0018",
        "\u0019", "\u001A", "\u001B", "\u001C", "\u001D", "\u001E", "\u001F"
);
$sChr = implode($aChr); 
$rrn = str_replace('"',"",$_POST['rrn']);
$rrn = str_replace($sChr, "", $rrn);

enter image description here

0 个答案:

没有答案