jquery.min.js:4 Uncaught TypeError: Illegal invocation code example

Example 1: jquery ajax Uncaught TypeError: Illegal invocation

This error is due to formData which is json object and by default ajax requrie
values to be in string format and as a solution

1. you can either remove formData and pass the values separately 
	data: { username: document.getElementById('createUserForm').value }

2. you can set the dataType to be 'json' and processData to be false
    
	$.ajax({
        url : base_url+'index.php',
        type: 'POST',
        dataType: 'json',
        data: data,
        cache : false,
        processData: false
    })

Example 2: jquery-3.4.1.min.js:2 Uncaught (in promise) TypeError: Illegal invocation

var form = $('#AddPersonnelForm')[0];
var frmData = new FormData(form);



processData: false,
contentType: false,

Tags:

Misc Example