JQuery: 'Uncaught TypeError: Illegal invocation' at ajax request

后端 未结 1 930
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 15:21

I am using this ajax function to post my form to a specific url .It is getting to the required url and processing but when it it return the result it is giving error.

         


        
相关标签:
1条回答
  • 2021-01-21 16:08

    I think the problem is with the data part of your ajax. serialize the form before send

    $.ajax({
        type: "POST",
        cache: false,
        url: $(this).attr('action'),
        enctype: 'multipart/form-data',
        data: $(this).serialize(),
        success: function (data) {
            alert("helo");
            if (data.success == true) {
                alert("The image is Uploaded");
            }
        },
        error: function () {
            alert(data.error);
        }
    
    });
    

    Edit

    $.ajax({
        type: "POST",
        cache: false,
        url: $(this).attr('action'),
        enctype: 'multipart/form-data',
        data: new FormData(this),
        processData: false,
        contentType: false,
        success: function (data) {
            alert("helo");
            if (data.success == true) {
                alert("The image is Uploaded");
            }
        },
        error: function () {
            alert(data.error);
        }
    
    });
    
    0 讨论(0)
提交回复
热议问题