ajax post方式application/json格式数据请求数据

 

 实现思路:

$.ajax( {type : "POST",
url : url,
contentType:"application/json",
dataType: "JSON",
async : false,
data : JSON.stringify({"name":"whj","age":"18","sex":"nv"}),
//data : {"id":"1","name":"whj","age":"18","sex":"nv"},
beforeSend: function(){

},
complete: function(){

},
success : function(data){//格式{key:value}
alert(data);
alert(data[0].name)


},
error: function(data) {
alert("error"); 
}

});
--------------------- 
作者:五年达尔文 
来源:CSDN 
原文:https://blog.csdn.net/weixin_40648117/article/details/78667540 
版权声明:本文为博主原创文章,转载请附上博文链接!

 


本文转载:CSDN博客