Uncaught TypeError: Illegal invocation Problem Solution

When using ajax upload files today, an error occurred. Data transmission mode is defined by formData completed, the file object is also submitted to dom object, but still can not send the request. F12 to see the backstage reported error: Uncaught TypeError: Illegal invocation, Baidu a bit to find a solution.

Solution: Add the parameter ajax request the following two parameters:

$.ajax({
   ...,
   processData:  false ,
   contentType:  false
   ...
});
processData

Type: Boolean

Default value: true. By default, data passed in through the option data, if an object (if not technically a string), the processing will be transformed into a query string to match the default content type "application / x-www-form-urlencoded . " If you want to send a DOM tree information or other information you do not wish to convert, set to false.

contentType

Type: String

Default: " application/x-www-form-urlencoded." When the server transmits content information to the encoding type.

The default value for most cases. If you explicitly pass a content-type to $ .ajax () then it must be sent to the server (even if there is no data to send).

Guess you like

Origin www.cnblogs.com/HIT-ryp/p/11566743.html