【发布时间】:2021-09-08 22:13:19
【问题描述】:
我有一个 AJAX POST,它从我的 PHP 文件 newPNRsubmit.php 发送回一个成功的响应:
if(isset($_POST['ticketentry'])){
$_SESSION['ticketEntry'] = 1;
header("location: pnr-details?id=".$pnrid);
}
但是我想使用我收到的 AJAX 响应到 window.location
这是回复:
XHR finished loading: GET "https://example.com/pnr-details?id=240".
这是我的 AJAX 结构:
$.ajax({
type: "POST",
url: "newPNRsubmit.php",
data: {
bookingdate: bookingdate,
airline_id: airline_id
},
cache: false,
success: function(data, url) {
$('#NewPNRModal').modal( 'hide' );
},
error: function(xhr, status, error) {
console.error(xhr);
}
});
return false;
如何正确地将收到的 URL 解析为 window.location?
更新:这是来自控制台选项卡的响应。第二个GET XHR 显示了我需要window.location 的链接。我应该更新标头位置以在我的PHP 文件中发送JSON 数据以使其正常工作吗?
【问题讨论】: