后台多个校验前台ajax接收


后台代码:
public void doNotNeedSessionAndSecurity_checkshopInfo() throws IOException {
  String msg = null;
  String shopInfoId = request.getParameter("lifeshopInfoId");
  shopInfo = shopInfoService.getShopInfoById(shopInfoId);
  if (shopInfo != null) {
   if (shopInfo.getStatus() == 3) {
    if (shopInfo.getFreezeStatus() == 1) {
     msg = "{\"success\":true}";
    } else {
     msg = "{\"success\":false,\"msg\":1}";
    }
   } else {
    msg = "{\"success\":false,\"msg\":2}";
   }
  } else {
   msg = "{\"success\":false,\"msg\":3}";
  }
  response.getWriter().write(msg);
 }
}
前台ajax:
function checkshopInfo() {
  if($("#lifeshopInfoId").val()!=''){
   $.ajax({
    type : "post", // 请求方式
    url : sys.contextPath + "/lifeCycleShop/ajax_lifeCycleShop/doNotNeedSessionAndSecurity_checkshopInfo", // 发送请求地址
    data : {
     "lifeshopInfoId" : $("#lifeshopInfoId").val()
    },
    dataType : "json",
    error : function() {
     $.messager.alert("提示","连接服务器超时,请稍后重试...","error");
     
    },
    success : function(result) {
      if (!result.success) {
       if (result.msg == 1) {
        $.messager.alert("提示","该服务机构关联的店铺已被冻结!", "error");
       } else if (result.msg == 2) {
        $.messager.alert("提示","该服务机构所关联的店铺已被下架!", "error");
       } else if (result.msg == 3) {
        $.messager.alert("提示", "该服务机构不存在!","error");
       }
      }
     }
    });
  }
 };
发布了28 篇原创文章 · 获赞 27 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/danruoshui315/article/details/44861769
今日推荐