Hey guys I am still a newbie in ajax. I have a problem with running JavaScript when the button clicked. All I want is, if I clicked the button I can run ajax so ajax can call PHP script and do query, at the same time can change page.
This is my html code
<input type="button" onclick="detailbayar()" value="Saya Sudah Bayar" data-theme="b">
function detailbayar()
{
$.ajax({
url: host+'/skripsi3/phpmobile/tenantmembayar.php',
data: { id: user,id1:getacara,id2:getorderID},
dataType: 'json',
success: function(result){
alert("Payment Accepted");
window.location.href="detailpesanan.html";
},
error: function(){
//output.text('There was an error loading the data.');
}
});
}
and this is my PHP code
<?php
session_start();
include "config.php";
$idtenant=mysql_real_escape_string($_POST["id"]);
$idacara=mysql_real_escape_string($_POST["id1"]);
$orderID=mysql_real_escape_string($_POST["id2"]);
date_default_timezone_set('Asia/Jakarta');
$tanggal = date("d M Y G:i");
$bayar="telahbayar";
$konfirmasi="On Process";
$query="UPDATE `preorder` SET `tanggalbayar`='$tanggal',`statuspesanan`='$konfirmasi',`statusbayar`='$bayar' WHERE id_tenant='$idtenant' && id_acara='$idacara' && id_order='$orderID'";
$result = mysql_query($query);
?>
Sorry for my bad English, Thank You and have a nice day.. Cheers!!