我试图使用使用JavaScript /jQuery$.get
方法的Ajax将一个JavaScript字典变量发送到PHP,但是它会产生一个错误。
以下是JavaScript代码:
$.get( "contr.php", { max: "max", max2: "max2" } );
和PHP:
$max = $_GET['max'];
var_dump($max);
$.get
工作PHP错误是:
未定义索引最大值
我做错了什么?
发布于 2019-06-07 14:24:37
这个错误是有帮助的。它说,传递给$.get
的字典变量省略了键值对data
-> max
。试试这个:
$.ajax({
url: "contr.php",
method:"GET",
data:{
max: "max"
max2: "max2"
}
}).done(function(response){
alert(response)
})
发布于 2016-10-17 15:47:38
试试这个:
$.ajax({
type: "GET",
url : "contr.php",
data: {
max : "max",
max2: "max2"
},
success : function(data){
// Do some stuff
console.log(data); // Use this to check the page response
}
})
请参阅此链接站点上的jQuery :)
发布于 2016-10-17 15:16:42
用以下代码替换Ajax代码:
$.get( "contr.php", { "max": "max", "max2": "max2" }, function(res){} );
https://stackoverflow.com/questions/40089982
复制相似问题