码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-07-29 10:12:39      阅读:195      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!