我有一个html按钮,它将使用jquery在POST请求中发送信息:
<button type="button" onclick="makePost();" id="person">View Person</button>
makePost()函数:
<script>
function makePost(){
$.ajax({
type: "POST",
url: "person.php,
data: {name: "John",
lname: "Stilton"},
dataType: "json",
success: function(response){
window.location.href = response.redirect;
}
});
}
</script>
我只想在person.php页面上回显数据,但是由于某种原因,用户在单击时不会重定向到person.php。 POST数据已成功发送到页面,由开发人员工具的“网络”标签中的预览显示。
如何将带有POST请求的用户重定向到同一页面?