我的代码在Mac OS Lion上的Safari 6.1.2以外的其他浏览器上运行得非常好.
以下是我使用的ajax帖子 -
$.ajax({
type: 'POST',
dataType: 'text/html',
url:"/MyProxy.php",
data:{"server":"mydomain.com", "user":"vijay", "passd":"highly@secret"},
error: function(data) {
console.log(data);
alert("Failure - "+data);
return;
},
success: function(data) {
console.log("Success - "+data);
parseInformation(data);
}
});
Run Code Online (Sandbox Code Playgroud)
同样出于调试目的,我在PHP服务器代码上输入了日志
header('cache-control: no-cache');
function getRealPOST() {
$pairs = explode("&", file_get_contents("php://input"));
$vars = array();
foreach ($pairs as $pair) {
$nv = explode("=", $pair);
$name = urldecode($nv[0]);
$value = urldecode($nv[1]);
$vars[$name] = $value;
}
return $vars;
}
echo "-------";
var_dump($_POST);
echo "-------";
print_r(getRealPOST());
Run Code Online (Sandbox Code Playgroud)
在Safari上的控制台日志中显示如下内容:
-------array(2) {
["userName"]=>
string(5) "vijay" …
Run Code Online (Sandbox Code Playgroud)