验证登录 多语言回报

 function Booking() {
        $.post("@Url.Action("DoToBook", "Booking")", null, function (data) {
            if (data.type == 1) {
                window.open("@Url.Action("Book", "Booking")")
                }
                else {
                    alert(data.message);
                }
         });
    
    }

前端代码

public JsonResult DoToBook()
        {
            if (Session["user"] == null)
            {
                return Json(CaptionController.TranCaption(JsonHelper.CreateMessage(0, "请先登录,在订舱","unlogin"), RouteData.Values["culture"].ToString()));
            }
            return Json(JsonHelper.CreateMessage(1, "", "")); ;
        }

一级判断

  public static JsonMessage TranCaption(JsonMessage json,string cul)
        {
            json.message = Models.Caption.GetCaption(json.value,cul);
            return json;
        }

二级判断

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CargoWeb.WebSite.Models
{
    public class Caption
    {

        public static string GetCaption(string id, string language)
        {

            try
            {
                return CargoWeb.WebSite.MvcApplication.listcap.Where(x => x.id == id).Select(x => language == "chs" ? x.chs : language == "us" ? x.us :  x.tw).FirstOrDefault().ToString();
            }
            catch (Exception e)
            {
                return "";
            }
        }
    }
}

三级回报

 

(type,message,value)

就是一行数据库

  alert("错误提示", strErrMsg, null, { type: 'warning' });//success

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值