zoukankan      html  css  js  c++  java
  • asp.net ajax get post 中文乱码解决办法

    前台:

    var username = $("#UserName").val();
    var tel = $("#tel").val();
    var yzm = $("#yzm").val();
    var con = $("#con").val();

    layer.msg('正在提交数据', { icon: 16 });


    var data = { "username": escape(username), "tel": escape(tel), "yzm": yzm ,"con":escape(con),"jxid":<%=Request["uid"].ToString() %>};


    $.post('ajaxpost.ashx?type=ask', data, function (rdata) {

    if (rdata == "ok") {

    layer.alert("提交成功,我们会尽快回复,请随时关注网站", { skin: 'layui-layer-molv', icon: 5 },function(index)
    {
    location.href="jiaxiao<%=Request["uid"].ToString() %>.aspx?x="+Math.random()+"#askhead";
    });

    }

    else {
    layer.alert(rdata, { skin: 'layui-layer-molv', icon: 5 });
    return;

    }

    });

    后台========================

    string con = code.NoHTML(HttpUtility.UrlDecode( context.Request["con"].ToString()));
    int jxid = int.Parse(context.Request["jxid"].ToString());
    string tel=code.NoHTML(HttpUtility.UrlDecode(context.Request["tel"].ToString()));
    string username=code.NoHTML(HttpUtility.UrlDecode(context.Request["username"].ToString()));
    string yzm = HttpContext.Current.Request["yzm"].ToString();

    总结:前台用js 的 escape 方法编码 后台HttpUtility.UrlDecode解码就可以了!

  • 相关阅读:
    北京大学计算机系2009应试硕士生上机考试(DF)
    我的考研2010(一)
    这张容易看懂...
    关于招商银行信用卡的若干事宜
    20 years
    C/C++中关于qsort的使用
    有道破题~~
    POJ 4010 2011
    有道难题练习赛 Sibonacci
    北京大学计算机系2009应试硕士生上机考试(AC)
  • 原文地址:https://www.cnblogs.com/efreer/p/5650284.html
Copyright © 2011-2022 走看看