Uncaught TypeError: Illegal invocation

Created at 24-Sep-2021 , By samar

Uncaught TypeError: Illegal invocation

In this session, we’ll try our hand at solving the "Uncaught TypeError: Illegal invocation" puzzle by using the computer language.

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.
  • 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

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.