Im doing the following ajax call:
$('#save_sale').click(function() {
var save_sale = 1;
$.ajax({
type: 'GET',
url: 'summary.php',
data: {save_sale: save_sale},
success: function(data) { /* Do something here?? */ },
error: function(xhr, ajaxOptions, thrownerror) { }
});
});
Here is my PHP:
function createSale()
{
if($sale_id = $this->link->inQuery("INSERT INTO nya_forsaljningar(personnr, status, datum) VALUES('".$this->personnr."','".$this->status."','".$this->sale_date."')"))
{
$this->link->inQuery("UPDATE services_temp SET active=1 WHERE temppdtls='".$this->personnr."'");
$this->link->inQuery("UPDATE summary_temp SET active=1 WHERE personnr='".$this->personnr."'");
header("Location: addcust.php?new_sale=$sale_id");
exit;
}
else
{
return false; //Kunde inte skapa f?rs?ljningen
}
}
if(isset($_GET['save_sale']))
{
$sale_date = date('Y-m-d'); //Datumet d? man skapar f?rs?ljning
$personnr = $_SESSION['fil'][3]; //Personnummer p? personen, anv?nder detta f?r att ta fram de olika delarna fr?n tabellerna
$save_true = $_GET['save_sale']; //F?rs?krar oss av att vi ska hantera en uppl?ggning av en nyf?rs?ljning
$new_sale = new newSale($personnr, $sale_date, $save_true, $link, $status='Obehandlad'); //Skapar ett objekt av f?rs?ljningen som vi anv?nder f?r att hantera den nya f?rs?ljning, kolla om den ?r ok, skapar kundbilden, nekar osv.
if($new_sale->checkService())
{
$new_sale->createSale(); //Skapar f?rs?ljningen
}
else
{
echo "Kunde inte skapa f?rs?ljningen";
exit;
}
}
After the sale is created, I want to redirect to addcust.php?new_sale=$sale_id
How can I accomplish this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…