ajax请求后,控制台报错: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

用ajax请求的,报错原因编码问题,加入contentType : 'application/json',就可以了

$.ajax({  
            type: "POST",   //提交的方法
            dataType: "json",
            contentType : 'application/json',//添加这句话
            url:"", //提交的地址    
            async: false,  
            data:JSON.stringify(str),

            error: function(request) {  //失败的话
                
            },  
            success: function(data) {  //成功
				
            }  
         }); 

 

你可能感兴趣的:(Web)