ajax能返回,但是不刷新当前页面。要强制刷新才管用
<br /><script type="text/javascript"> <br /> $(document).ready(function() {<br /> $(".quxiao").each(function(){<br /> $(this).click(function(){<br /> quxiao($(this)); <br /> })<br /> })<br /> });<br /> function quxiao(obj){<br /> var oid = $(obj).val();<br /> var oid = $(obj).parent().next().children(".oid").val();//获取节点<br /> //alert(oid);<br /> $.ajax({ //一个Ajax过程 <br /> type: "post", //以post方式与后台沟通 <br /> url : "xgkcg.php", //与此php页面沟通 <br /> dataType:'json', //从php返回的值以 json方式 解释 <br /> data: {oid:oid}, <br /> success: function()<br /> { //如果调用php成功 <br /> alert("成功取消订单!"); <br /> }<br /> });<br />} <br /></script><br />
<br /> require_once("config.php");<br /> header('content-type:application/json');<br /> $oid=$_POST['oid'];<br /> $sql="delete from `djs_shops_orders` where oid = '$oid'";<br /> $result = mysql_query($sql);<br /> $row = mysql_fetch_row($result);<br />
<br /><td><input id="quxiao" class="quxiao" type="button" value="取消"></td><br /> <td><input type="hidden" class="oid" id="oid" value="<?php echo $v['orderid']; ?>"></td><br />
success: function()<br /> { <br /> alert("成功取消订单!"); <br /> window.reload(); <br /> }
success: function()<br /> { <br /> alert("成功取消订单!"); <br /> $(obj).closest('tr').remove();<br /> }