Im doing the following ajax call:
$(\'#save_sale\').click(function() {
var save_sale = 1;
$.ajax({
type: \'GET\',
url: \'summary.php\
You can use JavaScript to redirect in the success handler:
success: function(data) {
window.location = 'newpage.php';
},
It can't be done with a PHP redirect, because that will only redirect the ajax call, not the original browser window.
If you want to use the sale ID in the URL then you will need to output it so it can be accessed:
$saleId = $new_sale->id; // or however you get the sale ID
echo json_encode(array('saleId' => $saleId)); // output JSON containing the sale ID
Ajax:
$.ajax({
type: 'GET',
url: 'summary.php',
dataType : 'json', // tell jQuery to parse the response JSON
data: {save_sale: save_sale},
success: function(data) {
window.location = 'addcust.php?new_sale=' + encodeURIComponent(data.saleId);
},
error: function(xhr, ajaxOptions, thrownerror) { }
});