I have an AJAX POST that is sending back a successful response from my PHP file newPNRsubmit.php
:
if(isset($_POST['ticketentry'])){
$_SESSION['ticketEntry'] = 1;
header("location: pnr-details?id=".$pnrid);
}
However I would like to use the AJAX response that I am receiving into window.location
This is the response:
XHR finished loading: GET "https://example.com/pnr-details?id=240".
This is my AJAX structure:
$.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;
How can I correctly parse the URL that I am receiving into window.location
?
UPDATE: This is the response from console tab. The second GET XHR
is showing the link I need for window.location
. Should I update the header location to send JSON
data in my PHP
file in order for this to work?
Either return a URL in the body instead of a header, or get the header like so:
success: function(data, URL, jqXHR) {
window.location.href = jqXHR.getResponseHeader("location");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.