gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 04:12:38 24 4
gpt4 key购买 nike

我有以下 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', and 'arguments' properties may not beaccessed on strict mode functions or the arguments objects for callsto them
    at 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

最佳答案

我认为不是严格模式的错误,只是控制台无法在严格模式下获取参数数组的内容。状态为 200,因此看起来 ajax 调用有效,但响应文本显示“无法上传文件”,因此我认为错误出在服务器端。

使用 TypeError 示例更新:

TypeError 只是说控制台在使用严格模式时无法获取参数数组的值。这不是代码错误。图中的简单示例演示了这一点。

Example of TypeError

关于javascript - Getting TypeError : 'caller' , 'callee' 和 'arguments' properties may not be accessed on strict mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52298691/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com