我使用此代码
function testfunction(ttl){
jQuery.ajax({url:"index.php",
type: "POST",
cache : false,
data: { 'data1': ttl},
success:function(res){
//Do something
},error: function(requestObject, error, errorThrown) {
console.log(error);
}});
}
我收到错误='错误'和errorThrown =“”
此问题仅适用于Google Chrome。
如何解决这个问题?
答案 0 :(得分:0)
以下代码对我有用 - 可能是您通过ajax调用发送的参数ttl的问题
的index.php:
<html>
<head>
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script language="JavaScript">
$('document').ready(function(){
$('button').click(function() {
$.ajax({
url: "index2.php",
type: "POST",
cache: false,
data: { 'data1': $(this).attr('rel')},
success: function (res) {
console.log(res);
},
error: function (requestObject, error, errorThrown) {
console.log(error);
}
});
});
});
</script>
</head>
<body>
<button rel="test">test</button>
</body>
</html>
和index2.php
<?php
echo json_encode($_POST);