修改头像 ajax上传图片,必须创建FormDate(),然后把图片加进去. ajax上传图片 $('#id_set_avatar_submit').click(function () { avatar_img = $('#id_avatar')[0].files[0]; var formData = new FormData(); formData.append('avatar_img', avatar_img); $.ajax({ url:"/set_avatar/", type:'post', data:formData, processData:false, contentType:false, success:function (data) { $('#avatar_errors').text(data.msg); } }) });