我试图在请求中将一个变量发送到同一个页面,然后检查是否设置了该变量。
$.ajax({
url: "index.php",
type: "POST",
data: {idss:idss},
success: function(data){
console.log("hello");
}
});
if(isset($_POST['idss'])){
echo "Set";
}然而,当它运行时,我只在控制台中看到"hello“,但是我没有在页面上看到'echo‘的输出。
我做错了什么吗?
发布于 2014-05-22 13:57:41
$.ajax({
url: "index.php",
type: "POST",
data: {idss:idss},
success: function(data){
console.log("hello");
$('#here').html(data['whatever_you_returned']);
}
});
<div id="here"></div>发布于 2014-05-22 13:55:19
POST数据将发送到ajax请求中的页面,而不是当前页面。index.php将拥有该POST数据集。
https://stackoverflow.com/questions/23808838
复制相似问题