zoukankan      html  css  js  c++  java
  • jQuery中文乱码解决方案

    jQuery遇到中文乱码问题,其实就是因为contentType没有指定编码,
    只需在jQuery.js中搜索
    'contentType'
    然后在application/x-www-form-urlencoded后面加上
    ; charset=UTF-8
    最终变成
    contentType:"application/x-www-form-urlencoded; charset=UTF-8"
    问题搞定。

    另外,也可在具体调用时指定

    contentType:"application/x-www-form-urlencoded; charset=UTF-8"参数,如:
    $.ajax({
                    type: "post",
                    url: "/my/login.aspx",
                    data: $('#loginform').serialize(),
                    dataType: "json",
                    contentType:"application/x-www-form-urlencoded; charset=UTF-8",
                    success: function (json) {
                        if (json.statusCode == 200) {
                            window.location.reload();
                        } else {
                            $("#J_logininfo").attr("class", "fail").html(json.message);
                        }
                    },
                    beforeSend: function (o) {
                        $("#J_logininfo").attr("class", "focus").html("登录中...");
                    }
                });
     
  • 相关阅读:
    前后端分类状态下SpringSecurity的玩法
    拓展 centos 7
    linux 日志管理
    Linux 内存监控
    Linux 周期任务
    Linux 文件系统
    linux 磁盘管理
    图论 最短路总结
    进阶线段树之乘法操作
    暑假集训Day 10 小烈送菜
  • 原文地址:https://www.cnblogs.com/leadwit/p/1971630.html
Copyright © 2011-2022 走看看