Uploading file in a form without page refresh

后端 未结 4 2072
野性不改
野性不改 2021-01-06 07:13

I have this bit of code:

4条回答
  •  被撕碎了的回忆
    2021-01-06 07:55

    You can post form with jQuery and get the result back.

    $('#formId' ).submit(
        function( e ) {
            $.ajax( {
                url: '/upload',
                type: 'POST',
                data: new FormData( this ),
                processData: false,
                contentType: false,
                success: function(result){
                    console.log(result);
                    //$("#div1").html(str);
                }
            } );
            e.preventDefault();
        } 
    );
    
    
            

提交回复
热议问题