ajax提交json格式数组


        var userArr = new Array();

        var user = {};
        user.name = "张三";
        user.age = 24;
        userArr.push(user);

        user.name = "李四";
        user.age = 26;
        userArr.push(user);

        $.ajax({
            url: "/mysql/lian/txlian",
            type: "POST",
            async: false,
            contentType : 'application/json;charset=utf-8', //设置请求头信息
//            dataType:"json",
            data: JSON.stringify(userArr),    //将Json对象序列化成Json字符串,JSON.stringify()原生态方法
//            data: $.toJSON(customerArray),            //将Json对象序列化成Json字符串,toJSON()需要引用jquery.json.min.js
            success: function(data){
                window.location.href="/mysql/lian/qrxxl";
            },
            error: function(res){
                alert(res.responseText);
            }
        });        

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM