您的位置:首页 > 其它

关于ajax的提交未完再续!

2016-01-25 00:50 405 查看
$.ajax({
cache: true,
type: "POST",
url:"__URL__/add",
data:$('#myform').serialize(),// 你的formid
async: false,
error: function(request) {
tichu('添加失败!','puti');
location.href="__URL__/add";
},
success: function(request) {
tichu('添加成功!','puti');
location.href="__URL__/add";
}
});


上面的提交方式可以将form表单id为myform的所有name值提交上去。

  if($rt){
    echo 1;exit;
  } else {
    echo 2;exit;
  }

上面是我的返回

function u(id){
var sort = $('#p_sort').val();
//                                                        layer.confirm('确认要更改排序吗?',function(index){
//alert('__APP__/Back/Product/Up_id/id/'+id+'/sort/'+sort);
//                                                          return false;
$.get('__APP__/Back/Product/Up_id/id/'+id+'/sort/'+sort,function(mm){
if (mm==1) {
//                                                                    $(obj).parents("tr").remove();
layer.msg('设置成功!',{icon:1,time:1000});
location.reload();
}else{
layer.msg('设置失败!',{icon:1,time:1000});
location.reload();
}
});
//                                                                        });
//                                                        location.reload();
}


这种也是ajax返回格式

$.ajax({
cache: true,
type: "GET",
url: "{:U('Back/GoodsClassify/del')}",
data: {id: id,two_id: two_id},
async: false,
error: function (request) {

},
success: function (request){
if(request==1){
$(obj).parents("tr").remove();
layer.msg('已删除!',{icon:1,time:1000});
}else if(request==2){
layer.msg('已删除!',{icon:1,time:1000});
location.reload();
}else{
layer.msg('删除失败!',{icon:1,time:1000});
}
}
});


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: