Answer the question
In order to leave comments, you need to log in
[AJAX / JQUERY] Uncaught TypeError: Illegal invocation?
function ajax ($data){
let setup = {};
// $data является либо new FormData(), либо объектом
if ($data instanceof FormData) {
setup = {
processData: false,
contentType: false
};
}
$.ajaxSetup({
url: "/dummy_url",
type: "POST",
data: $data,
dataType: "JSON",
cache: false
});
return $.ajax(setup);
}
$response
array is returned to the variable with links to scripts that need to be loaded depending on the form parameters:$.each($response, function (k, v) {
$.getScript(v);
});
Uncaught TypeError: Illegal invocation
at i (jquery-3.3.1.min.js:2)
at jt (jquery-3.3.1.min.js:2)
at Function.w.param (jquery-3.3.1.min.js:2)
at Function.ajax (jquery-3.3.1.min.js:2)
at Ajax.self.request (app.ajax.js:40)
at HTMLFormElement.<anonymous> (account.function.js?0.1:55)
at HTMLDocument.dispatch (jquery-3.3.1.min.js:2)
at HTMLDocument.y.handle (jquery-3.3.1.min.js:2)
let $data = {id: 1, value: "dummy_value"}
Answer the question
In order to leave comments, you need to log in
Specify additional options in $.ajaxSetup
var $data = new FormData();
$.ajaxSetup({
url: "/dummy_url",
type: "POST",
data: $data,
processData: false,
contentType: false,
dataType: "json",
});
$.getScript('/url');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question