Php 在Safari中,为什么jQueryAjax调用后$\u POST数组是空的?
仅在Safari中,为什么在使用jQuery AJAX调用发布时,Php 在Safari中,为什么jQueryAjax调用后$\u POST数组是空的?,php,javascript,jquery,ajax,safari,Php,Javascript,Jquery,Ajax,Safari,仅在Safari中,为什么在使用jQuery AJAX调用发布时,$\u POST数组为空 IE、Firefox和Chrome都输出正确 <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> <script type="text/javascript"> $(d
$\u POST
数组为空
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>
并输出如下:
Array
(
)
请尝试删除
数据中的(
和)
该问题可能与iOS 6缓存某些post请求有关。请查看此帖子:
您可以通过检查是否正在使用无缓存控制头或“缓存控制:最大年龄=0”并删除它们来测试这一点。首先,您将数据类型设置为xml,我想这应该是html,因为您没有将xml作为响应。见:
引号:“为什么数据是括号中的对象?”
如果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));
}
});
});
刚刚将成功更改为:
成功:函数(数据){alert(字符串(数据));}
编辑:它在所有浏览器中都给了我相同的结果。我的一位同事找到了答案:
希望这对其他人有所帮助…为什么数据
是括号中的一个对象?我更新了上面的代码,但post数组仍然是空的:(我将在几小时后尝试重新创建它。您好,此链接中的解决方案似乎在所有浏览器中都有效。您能看一下吗?(顺便说一句,我对php返回数组的方式有点惊讶)
$(document).ready(
function()
{
$.ajax(
{
type: "POST",
url: "target.php",
async :true,
dataType: "html",
data: {
'param1': 'param1'
},
success: function(data) {
alert(String(data));
}
});
});