ajax能返回,但是不刷新当前页面。要强制刷新才管用 1、你的 xgkcg.php 没有输出2、你执行的是删除指令,mysql_fetch_row($result) 只会报错 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ajax是不能自动刷新页面的,可以如下实现success: function() { alert("成功取消订单!"); window.reload(); }或者不刷新的话 调用代码删除success: function() { alert("成功取消订单!"); $(obj).closest('tr').remove(); } php的代码我又写成这样了,感觉挺不规范的,不知该如何改进? require_once("config.php"); header('content-type:application/json'); $oid=$_POST['oid']; $sql="delete from `djs_shops_orders` where oid = '$oid'"; $result = mysql_query($sql); if($result){ return true; }else{ return false; } require_once("config.php"); header('content-type:application/json'); $oid = addcslashes($_POST['oid']);//转义字符 $sql = "delete from `djs_shops_orders` where oid = '$oid'"; mysql_query($sql); if(mysql_affected_rows() > 0){//影响条数 return true; }else{ return false; } 加上转义字符就不能执行sql语句了。有没有什么更好的办法 你吧$sql打印出来看看 不能执行报什么错误了吗? 急寻PHP开发工程师(精通韩语) 小问题 php怎么放入html页面 ? php菜鸟请教个问题 如何通过PHP实现域名跳转 现在很多网站多有:最近浏览记录.是怎么做的? 品牌空间二次开发的高手请进 请高手指点这几句代码什么意思 支付宝 接口 代码运行报错 微信自带的浏览怎么才可以记住密码 thinkphp里 表单提交数组的问题 php 导出数据,格式为csv
success: function()
{
alert("成功取消订单!");
window.reload();
}
或者不刷新的话 调用代码删除
success: function()
{
alert("成功取消订单!");
$(obj).closest('tr').remove();
}
php的代码我又写成这样了,感觉挺不规范的,不知该如何改进?
require_once("config.php");
header('content-type:application/json');
$oid=$_POST['oid'];
$sql="delete from `djs_shops_orders` where oid = '$oid'";
$result = mysql_query($sql);
if($result){
return true;
}else{
return false;
}
header('content-type:application/json');
$oid = addcslashes($_POST['oid']);//转义字符
$sql = "delete from `djs_shops_orders` where oid = '$oid'";
mysql_query($sql);
if(mysql_affected_rows() > 0){//影响条数
return true;
}else{
return false;
}