0

我正在尝试通过对当前页面发出的发布请求将值“hi”发送到 php 变量“text”。

jQuery

$.post("", "hi");

php

if (isset($_POST['POST'])) {
  $text = $_POST['POST'];
}
4

2 回答 2

2

JS:

$.post("", {data:"hi"},function(data){

});

PHP:

if (isset($_POST['data'])) {
  $text = $_POST['data'];
}
于 2012-10-12T14:49:27.677 回答
0

像这样做:

$.post("", "text=hi");// You have to pass "key=value" pairs

在 PHP 中:

if (isset($_POST['text'])) {
  $text = $_POST['text']; //$text will contain 'hi'
}
于 2012-10-12T14:48:41.317 回答