title: Redirect AJAX response URL from PHP header
body: <p>I have an AJAX POST that is sending back a successful response from my PHP file <code>newPNRsubmit.php</code> :</p>
  <pre><code>if(isset($_POST['ticketentry'])){
              $_SESSION['ticketEntry'] = 1;
              header(&quot;location: pnr-details?id=&quot;.$pnrid);
          }
  </code></pre>
  <p>However I would like to use the AJAX response that I am receiving into <code>window.location</code></p>
  <p>This is the response:</p>
  <pre><code>XHR finished loading: GET &quot;https://example.com/pnr-details?id=240&quot;.
  </code></pre>
  <p>This is my AJAX structure:</p>
  <pre><code>$.ajax({
   type: &quot;POST&quot;,
   url: &quot;newPNRsubmit.php&quot;,
   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;
  </code></pre>
  <p>How can I correctly parse the URL that I am receiving into <code>window.location</code> ?</p>
  <p>UPDATE: This is the response from console tab. The second <code>GET XHR</code> is showing the link I need for <code>window.location</code>. Should I update the header location to send <code>JSON</code> data in my <code>PHP</code> file in order for this to work?</p>
  <p><a href="https://i.stack.imgur.com/aGV4q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aGV4q.png" alt="enter image description here" /></a></p>