首页 > Web开发 > 详细

JQuery ajax url传值与data传值的区别

时间:2015-07-29 10:11:20      阅读:298      评论:0      收藏:0      [点我收藏+]

url传中文,乱码,即便charset为 UTF-8,

$.ajax({
    type: "POST",
    cache: false,
    url: "/ProductTypeAndCat/AddType?typeName=" + typeName,
    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
    datatype: "JSON",
});

技术分享

data传中文,正确。

$.ajax({
    type: "POST",
    cache: false,
    url: "/ProductTypeAndCat/AddType",
    data: {typeName:typeName},
    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
    datatype: "JSON",
    success: function (data) {
        if (data.F == 0) {
            alert("添加陈功");
            location.href = "/Admin/ProductType";
        }
        else {
            alert(data.M);
        }
    },
    error: function (xhr, status, error) {
        alert(error);
    }
});

技术分享

技术分享

JQuery ajax url传值与data传值的区别

原文:http://www.cnblogs.com/luminji/p/4685127.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!