- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
感谢您分享我的头痛 - 这是简短的说明:
最近继承了一个编码很差的 WordPress 网站 - 该网站利用了 WP Contact Form 7 -
我剥离了所有 WP-CF 代码(因为 WordPress 在移交给我之前就已经被剥离了)——只是为了制作一个简单的补丁脚本并继续实际工作。
我用这个脚本替换了 WPCF 脚本:(让事情对我来说尽可能简单):
jQuery(document).ready(function() {
$ = jQuery;
console.log("Ready");
$("#quack-button").click(function(e) {
console.log("Quack");
e.preventDefault();
e.stopPropagation();
POSTDATA = $.param($("#quack-form").serializeArray());
$.ajax({
method : "POST",
url : "http://www.domain.com/contact.php",
data : POSTDATA,
success : function(response) {
console.log(response);
alert("Thank you ! We'll get in touch as soon as we can -! ");
}
});
});
});
但是,在尝试了 $.param
和 serialize
的许多不同形式/组合之后 -服务器端脚本继续返回一个空白数组....
print_r($_POST);
但是,当我将其更改为 print_r($_REQUEST)
时 - 一切正常,很好......
现在,这可能会以什么方式发生?我错过了哪些盲点可能会造成这种情况......?
这是我一段时间以来遇到的最令人困惑的事情...我很感激任何人对此的理解...
最佳答案
如果您想将其作为 $_POST
发送,请更改此行:
method: 'POST'
对此:
type: 'POST'
根据docs ,就是这样设置的。
type (default:
'GET'
)
Type: String
The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.
关于php - $_REQUEST 有效,但 $_POST 无效 -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25634817/
下面的代码可以从数据库中删除行,但不能插入。这是为什么? 最佳答案 试试这个: mysql_connect("localhost","formuser","password") or die(mys
在 /app/models/review.rb ,我有一种方法,旨在从 review#print 的输出创建 PDF行动。还旨在捕获我的整个打印样式表并在我处于生产模式时将其内联到标题中: def c
我有一个搜索表单,我想将搜索词 $_REQUEST 作为一个数组,这样我就可以列出每个搜索词,将每个词包装在一个跨度中以进行样式设置。我怎么做? 编辑:这是请求的代码。 更新:谢谢大家的回答
PHP 超全局变量 PHP 具有可以在脚本的任何范围内访问的全局变量。其中三个变量($_GET、$_POST、$_COOKIE)存储在第四个变量($_REQUEST >). $_GET An asso
我对 php 中的 $_REQUEST 全局变量有疑问。当您使用相同的变量名提交了一个 get 和一个 post 时,php 会为它们中的任何一个分配优先级吗? IE。如果我将 $_POST['var
考虑以下代码片段: 图表 A: $_REQUEST = json_decode(stripslashes(json_encode($_REQUEST, JSON_HEX_APOS)), true);
我有这个代码。 $message = ""; if($_REQUEST['msg'] == "new"){ $message = "New User has been added succes
我正在开发 ZEND 框架,这对我来说是新的,AJAX 也是如此。我尝试了很多例子,但没有一个起作用。 请告诉我这段代码是错误的。 home.phtml
我想将一个变量传递给我的 Controller ,并且无论其请求方法(POST 或 GET)如何,我都需要获取它的值,相当于 $_REQUEST['myvar'],我该怎么做? 最佳答案 要获取作为路
我正在尝试从 URL 向我的 facebook 应用程序传递一些变量,即像 facebook 想要的那样使用 GET 变量 app_data 。 在某些时候,我已经停止获取 $_REQUEST 的 [
我有一个与外部 API 交互的应用程序。当远程服务发布包含特定状态的请求时,我需要通过外部 URL 将该帖子的全部内容重新发送到不同的应用程序。 是否可以获取整个 $_REQUEST 并将其重新发布到
首先我要说的是我并不真正了解 PHP...我正在为一个项目摆弄它。 我正在将数据从 Java 程序发布到我的 .php 文件。我当前的问题是,现在我希望我的 Java 函数将数据发布到 PHP 文件,
我无法使用 PHP 获取文本字段 new_list_id 的值。这是我的代码: New Input 101 102 var selectm
我有一个将数据插入 mySQL 的表单。效果很好。 提交后,我有一个显示“part_no”的成功页面。我还需要显示“add_qty”。 如何更改我的帖子脚本以在成功页面上显示两个字段数据? 这是我的代
运动选项的类型是从我拥有所有运动类型的数据库中选择的。Type_sport 包含运动的名称。一切都很好,数据库中的所有运动都显示在选项列表中。但是,当选项来自数据库时,我如何 $_REQUEST 用户
我在 html 文件中有表单,它是文件正文 function f() { var name = document.getElement
我有一些像这样的简单代码: "; echo $_COOKIE['user']; ?> 这是结果: Notice: Undefined index: user in D:\interpub\wwwroo
我最近在 PHP 脚本中遇到了这一行: $_REQUEST['start_date']=$date; 以任何方式为 super 全局 $_REQUEST 变量赋值是否允许或有用?如果有 $_COOKI
$p = (isset($_REQUEST["p"])?$_REQUEST["p"]:""); 这是我通常在我的 php 代码中使用的公共(public)行。我总是假设是否有更好(更小和更快)的方式来
最近我遇到了一些与 PHP 相关的流行答案,建议使用超全局 $_REQUEST,我认为这是代码味道,因为它让我想起了 register_globals. 您能否提供一个很好的解释/证据来说明为什么 $
我是一名优秀的程序员,十分优秀!