Redirect with PHP after ajax call

You redirect in success:

$('#save_sale').click(function() {
    var save_sale = 1;
    $.ajax({
        type: 'GET',
        url: 'summary.php',
        data: {save_sale: save_sale},
        success: function(data) { 
                window.location.href="https://stackoverflow.com/questions/23807411/addcust.php?new_sale=" + data
            },
        error: function(xhr, ajaxOptions, thrownerror) { }
    });
});

Whatever you echo back from the PHP script will be in data. So echo $sale_id and you’ll have your URL.

Leave a Comment