Send file with ajax of jQuery to web service in C# (asmx)

前端 未结 3 798
北海茫月
北海茫月 2021-01-02 12:43

I\'m using web service with this method:

        $.ajax({
            type: \'POST\',
            url: \'page.asmx/method\',
            contentType: \'appli         


        
3条回答
  •  抹茶落季
    2021-01-02 13:14

    You can send form object like : new FormData($(this)[0]) which send both input values and file object to the ajax call.

    var formData = new FormData($(this)[0]);
    $.ajax({
        type: 'POST',
        url: 'page.asmx/method',
        data: formData,
            async: false,
            success: function (data) {
                alert(data)
            },
            cache: false,
            contentType: false,
            processData: false
    });
    

提交回复
热议问题