我在我目前正在开发的一个应用程序中使用 noty jquery 通知http://needim.github.com/noty/ 。它提供了“确认”功能,但我想在访问者按“确定”时在 php 中执行某些操作,并在访问者按“取消”时执行其他操作。如何将此功能添加到我的脚本中?到目前为止,我的代码(特定段)是以下代码:
<?php
//add2cart section
if(isset($_POST['add2cart'])){
//$plus1 = +1;
$order_date = date("Y/m/d");
$img_name = $_POST['img_name'];
//$color = $_POST['color'];
$sqldata = "select * from orders where img_name = '$img_name' and
sess_user = '$user and checkout= ' ' ";
$dataselect = mysql_query($sqldata);
$sqlnum = mysql_num_rows($dataselect);
if($sqlnum >= 1){?>
<script type="text/javascript">
noty({"text":"This item is already in your cart.
Are you sure you want to add it one more time?","layout":"center","type":"confirm","textAlign":"center","easing":"swing","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":"500",buttons: [
{type: 'button green', text: 'Ok', click: function($noty) {
// this = button element
// $noty = $noty element
//$noty.close();
noty({force: true, text: 'You clicked "Ok" button', type: 'success'});
}
},
{type: 'button pink', text: 'Cancel', click: function($noty) {
//$noty.close();
noty({force: true, text: 'You clicked "Cancel" button', type: 'error'});
}
}
],
closable: false,
timeout: false});
</script>
<?php
}else{?>
<script type="text/javascript">
noty({"text":"Item added.","layout":"center","type":"success","textAlign":"center","easing":"swing","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":"500","timeout":"3000","closable":true,"closeOnSelfClick":true});
</script>
<?php
$sizevalue = '5\" x 7\"(13 x 19 cm)';
$sql_order ="insert into orders(item_id, img_name, quantity, color, order_date, sess_user, size, unique_id) values(' ', '$img_name', '1', 'Color', '$order_date', '$user', '$sizevalue', '$unique_id')";
mysql_query($sql_order);
}
}
?>
我会很感激任何帮助,谢谢你的时间。