« on: 19, 12, 2012, 08:10:28 »
http://api.jquery.com/jQuery.post/demo.php
<script type="text/javascript">
$(document).ready(function() {
$("#dialog").dialog({
autoOpen: false,
modal: true,
buttons : {
"Confirm" : function() {
var wk_id = $("#callConfirm").attr("title");
//--alert("You have confirmed!");
updateAck(wk_id);
$("#dialog").dialog("close");
},
"Cancel" : function() {
$(this).dialog("close");
}
}
});
$("#callConfirm").on("click", function(e) {
e.preventDefault();
$("#callConfirm").attr("disabled", "disabled");
$("#dialog").dialog("open");
});
});
function updateAck(wk_id) {
$.post("updateAck.php", { id: id},
function(data){
console.log(data.SQL);
console.log("update status accept : "+data.STATUS);
if(data.STATUS){
alert("Accept Success!");
}else{
alert("Can't accept this time! Please try again!");
}
},"json");
}
});
</script>
<button id="callConfirm" title="<?php echo$_GET['id'];?>">Accept</button>
<div id="dialog" class="dialog" title="Confirmation Required">
Confirm this item ?
</div>
update.php
<?php
function connectSQL($servername,$databasename,$user_encode,$password_encode){
$user = base64_decode($user_encode);
$pass = base64_decode($password_encode);
$connection_string ="DRIVER={SQL Server};SERVER=$servername;DATABASE=$databasename;AutoTranslate=no";
$conSQL = odbc_connect($connection_string,$user, $pass) or die ("can't connect server");
return $conSQL;
}
$connection= connectSQL('server_name', 'db_name', base64_encode('user'), base64_encode('password'));
$id= $_POST['id'];
$sql="Update <your_table> Set field_name='<value>' Where <field_name>='{$value}'";
$objQuery=odbc_exec($connection,$sql);
if($objQuery){
$STATUS=true;
}else{
$STATUS=false;
}
echo json_encode(array("STATUS"=>$STATUS,"SQL"=>$sql));
?>
« Last Edit: 19, 12, 2012, 08:13:35 by aegkaluk »

Logged