使用ajax上传文件

$('#submit').on('click',function(){
    
    var form= new FormData($('#n_form')[0]);
    $.ajax({
        url: '/admin/notice/noticeadd',
        type: 'POST',
        data: form,
        processData:false,
        contentType:false,
        dataType: 'json',
        success: function (info) {
            console.log(info);
        },
        error: function (data) {
            alert('ajax出错啦');
        }
    });
})

猜你喜欢

转载自blog.csdn.net/weixin_39712497/article/details/80335143