ajax 两者有什么不同

$.ajax({
            type:"POST",
            url:url,
            //dataType:"json",
           // contentType: "application/json",
            data:JSON.stringify(smalltarget),
            success:function (data) {
                console.log(data);
                if(data.result){
                    sid=[];
                    content=[];
                    smalltarget=[];
                }else{
                    layer.msg("数据更新不成功!",{offset:"100px"});
                }
            }
        });

$.post(
        url,
        {data:JSON.stringify(smalltarget)},
        function(data){
            if(true){
                sid=[];
                content=[];
                smalltarget=[];
            }else{
                alert(result);
                layer.msg("数据更新不成功!",{offset:"100px"});
            }
        });   

1.JSON.stringify(smalltarget)是字符串类型,不再是json了。

2.springmvc接受的是key value值,第一种是嘛,一定要把原理弄清。

原文地址:https://www.cnblogs.com/wlhebut/p/7889945.html