首页 > 代码库 > ajax data数据里面传一个json到后台的写法

ajax data数据里面传一个json到后台的写法

$.ajax({
                url:url+"/crm/contact",
                type:‘PUT‘,
                contentType: "application/json",
                timeout : "3000",
                cache:false,
                data: JSON.stringify({
                    "id":n,
                    "name":$(‘.pop_name‘).val(),
                    "phone":$(‘.pop_phone‘).val(),
                    "email":$(‘.pop_email‘).val(),
                    "position":$(‘.pop_position‘).val(),
                    "enterprise": {‘id‘: 1}
                }),
                dataType: "json",
                success:function(str){
                    //弹窗关闭
                    $(‘.pop‘).hide();
                    window.location.reload();
                },
                error:function(err){
                    alert("数据刷新失败,请重新刷新");
                }
            });

转自:http://www.cnblogs.com/shiyou00/p/5687553.html

ajax data数据里面传一个json到后台的写法