Получение TypeError: в строгом режиме нельзя получить доступ к свойствам 'caller', 'callee' и 'arguments' - PullRequest
0 голосов
/ 12 сентября 2018

У меня есть такой код jQuery:

$(document).ready(function() {

  $('.btn-create-post-card').on('click', function(event) {
    event.preventDefault();
    let form_data = new FormData(),
      file = $('.input_file_button');
    // if(!file.val()) {
    //     alert('Please select postcard you want to send')
    // }
    form_data.append("file", file.prop('files')[0]);
    $.ajax({
      url: "/sendEmail",
      dataType: 'multipart/form-data',
      cache: false,
      contentType: false,
      processData: false,
      data: form_data,
      type: 'post',
      success: function(data) {
        alert('OK');
      },
      error: function(error, status) {
        console.log('here');
        console.log(error);
        alert(error);
      }
    });
  });
});

И я получаю ошибку:

TypeError: свойства 'caller', 'callee' и 'arguments' не могут быть доступ к функциям строгого режима или объектам аргументов для вызовов им
в Function.remoteFunction (: 2: 14)

Вывод на консоль: enter image description here

Как видите, ответ успешен, и я много раз использовал вызовы jQuery AJAX и никогда не сталкивался с такой проблемой.

Изменено:

вывод на консоль:

abort: ƒ (e)
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 1
    name: "abort"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
always: ƒ ()
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 0
    name: "always"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
catch: ƒ (e)
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 1
    name: "catch"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
done: ƒ ()
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 0
    name: "add"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
fail: ƒ ()
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 0
    name: "add"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
getAllResponseHeaders: ƒ ()
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 0
    name: "getAllResponseHeaders"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
getResponseHeader: ƒ (e)
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 1
    name: "getResponseHeader"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
overrideMimeType: ƒ (e)
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 1
    name: "overrideMimeType"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
pipe: ƒ ()
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 0
    name: "pipe"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
progress: ƒ ()
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 0
    name: "add"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
promise: ƒ (e)
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 1
    name: "promise"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
readyState: 4
responseText: ""can't upload file""
setRequestHeader: ƒ (e,t)
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 2
    name: "setRequestHeader"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
state: ƒ ()
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 0
    name: "state"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
status: 200
statusCode: ƒ (e)
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 1
    name: "statusCode"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
statusText: "OK"
then: ƒ (t,r,i)
    arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (<anonymous>:2:14)]
    length: 3
    name: "then"
    prototype: {constructor: ƒ}
    __proto__: ƒ ()
    [[FunctionLocation]]: jquery.min.js:2
    [[Scopes]]: Scopes[3]
__proto__: Object

Ответы [ 2 ]

0 голосов
/ 12 сентября 2018

хорошо, я нашел проблему. Проблема была в dataType: 'multipart/form-data', и после удаления все работает. Я думаю, что это работает на другой машине, потому что версия браузера на этой машине не поддерживает строгий режим. Спасибо за помощь

0 голосов
/ 12 сентября 2018

Я не думаю, что строгий режим является ошибкой, просто консоль не может получить содержимое массива arguments в строгом режиме.Состояние равно 200, поэтому похоже, что сработал вызов ajax, но в тексте ответа написано «невозможно загрузить файл», поэтому я думаю, что ошибка на стороне сервера.

Обновление с примером TypeError:

То, что TypeError просто говорит, что консоль не может получить значения массив аргументов при использовании строгого режима.Это не ошибка с кодом.Простой пример на рисунке демонстрирует это.

Example of TypeError

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...