在Safari中,为什么jQuery AJAX调用后$_POST数组为空?
In Safari, why is the $_POST array empty after jQuery AJAX call?
在Safari只有,为什么是$_POST
数组空时张贴使用jQuery AJAX调用?
IE, Firefox和Chrome都能正确输出。
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function()
{
$.ajax(
{
type: "POST",
url: "target.php",
dataType: "xml",
data: ({
'param1': 'param1'
}),
success: function()
{
}
});
});
</script>
<title></title>
</head>
<body>
</body>
</html>
文件target.php
包含如下代码:
<?php print_r($_POST); ?>
并输出如下内容:
Array
(
)
尝试删除data
中的(
和)
这个问题可能与iOS 6缓存某些post请求有关。看看这篇文章:ios缓存post请求响应。
你可以通过检查是否没有使用Cache-Control头或"Cache-Control: max-age=0"并删除它们来测试这一点。
首先你设置的数据类型为xml,我猜这应该是html,因为你没有得到xml作为响应。参见:http://docs.jquery.com/Specifying_the_Data_Type_for_AJAX_Requests
quote: "为什么data是括号中的对象?"
如果Mark roper是正确的,也可以在请求中使用async: true。
$(document).ready(
function()
{
$.ajax(
{
type: "POST",
url: "target.php",
async :true,
dataType: "html",
data: {
'param1': 'param1'
},
success: function(data) {
alert(String(data));
}
});
});
把success改成:success: function(data) {alert(String(data));}编辑:在http://peervantienen.com/Stackoverflow/in-safari-why-is-the-post-array-empty-after-jquery-ajax-call/上它给了我相同的结果在所有浏览器
我的一个同事找到了答案:
http://forums.iis.net/post/1999417.aspx相关文章:
- 使用application/x-www-form-urlencoded使用node.js在post请求中发送数组
- 使用 $.post 发送数组
- AJAX中的POST数组
- 如何使用javascript将所选项目放入php post数组中
- node.js请求POST数组“;第一个参数必须是字符串或缓冲区;
- 获取 Ajax $.post 数组响应
- 在动态输入区域jquery中获取post数组以插入批代码点火器
- $_POST 变量保持活动状态多长时间,PHP 如何决定 post 数组中的内容
- 从窗口模式的PHP POST数组
- 多维数组的多复选框组值jQuery post数组AJAX
- Php post数组数据到服务器
- 如何Post数组多维角js
- 使用javascript和php增加一个值,并将其保存在POST数组中
- Post数组从JavaScript到PHP Post
- 使用AJAX将表单数组作为POST数组发送到PHP
- 什么's提交表单后,从post数组中动态附加的表行字段中获取值的问题
- PHP返回空POST数组
- 无法从外部PHP文件中的AJAX调用中读取POST数组
- 我如何在发送到服务器之前生成POST数组作为客户端/ JavaScript对象
- POST数组与jQuery和Ajax