Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode

I have such jQuery code:

$(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);
      }
    });
  });
});

And I'm getting error:

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 (:2:14)

Console output is: enter image description here

As you can see response is successful and I used jQuery AJAX calls a lot before and never had such issue.

Updated:

console output:

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
like image 941
Bogdan Dubyk Avatar asked Sep 12 '18 15:09

Bogdan Dubyk


2 Answers

I don't think strict mode is the error, it's just that the console can't get the contents of the arguments array in strict mode. The status is 200 so it looks like the ajax call worked, but the response text says "can't upload file", so I think the error is on the server side.

Update with TypeError example:

That TypeError just says the console can't get the values the arguments array when using strict mode. It's not an error with the code. The simple example in the image demonstrates this.

Example of TypeError

like image 96
Jacob Mouka Avatar answered Nov 08 '22 08:11

Jacob Mouka


I found the issue: it was in dataType: 'multipart/form-data' and, after I remove it, everything is working.

I think it worked on a different machine because the browser version on that machine does not support strict mode.

like image 31
Bogdan Dubyk Avatar answered Nov 08 '22 10:11

Bogdan Dubyk