1.引入jqueryjavascript
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
2.请求html
$.ajax({ url: '', data: fd, type: 'POST', contentType:false, //必须false才会避开jQuery对 formdata 的默认处理 , XMLHttpRequest会对 formdata 进行正确的处理 processData: false, //必须false才会自动加上正确的Content-Type success: function(res){ console.log(res); //res = JSON.parse(res); //JSON.stringify(res.data) }, error: function(err){ console.log(err); } });