Uncaught TypeError: Illegal invocation

Sometimes you got error Uncaught TypeError: Illegal invocation while submit a form using ajax in javascript. There could be any reason for this error but in my case I have found this error because I did not pass the the processData: false, to $.ajax() settings.

Answers 1
  • Solution for error uncaught TypeError: Illegal invocation

    <!-- processData: false, to ajax settings -->
    $('#form').on('submit', function(e){
        var formData = new FormData($(this)[0]);
            type: "POST",
            dataType: "json",
            processData: false,
            url: "/add-record",
            data: formData,
            success: function(data){
                return 'response';

    Add processData: false, as key/value pair to ajax settings to avoid the error Uncaught TypeError: Illegal invocation while calling ajax on form submit.

  • Back to code snippet queries related javascript