[Solved] Jquery ajax “Uncaught TypeError: Illegal invocation”

JQuery Ajax “uncaught typeerror: illegal invocation” refers to jQuery’s Ajax error: uncaught type error: illegal call

after checking jQuery’s document, it is found that if it is not a string, jQuery’s attempt to convert data into a string. Therefore, we need to add an option: processd ata:false Tell jQuery not to touch my data here! Another alternative is contentt ype:false To prevent jQuery from adding a content type header for you, otherwise the string will be lost and the upload will fail. The final Ajax code looks like this:

 

$.ajax({
    url: url,
    type: 'POST',
    data: formdata,
    contentType: false, //MUST
    processData: false, //MUST
    dataType: 'json',
    success: callback
});

 

Similar Posts: