尝试使用谷歌搜索,并在这里找到了解决方案,但我怕我的JavaScript知识根本就不够好。
Tried to find the solution using Google and searching here, but I'm afraid my knowledge of javascript is simply not good enough..
我有一个简单的网站手风琴和一些JavaScript。 在Firefox一切工作,因为它应该,但在IE11我得到一个SCRIPT1003:预期':'错误。 我把范围缩小到这一和平code。在我的.js文件:
I'm having a simple site with an accordion and some javascript. In Firefox everything is working as it should, but in IE11 I get a SCRIPT1003: Expected ':' error. I narrowed it down to this peace of code in my .js file :
var nmArray = new Array();
function saveplayers() {
var x;
for (x=0;x<32;x++) {
var y = "i"+eval(x+1);
nmArray[x]=document.getElementById(y).value;
}
var request = $.ajax({
type: "POST",
url: "savep.php",
data: ({ nmArray }),
cache: false
});
}
错误抱怨,应该有nmArray后结肠中({nmAray}) 如果我拿这个功能出来,我的网站再次工作...顺便说一下,对于调试我剥夺了我的HTML,我甚至不调用此函数。我只是包括.js文件。
The error complains that there should be a colon after nmArray in ({ nmAray }) If I take this function out, my site works again...By the way, for debugging I stripped down my HTML, and I'm not even calling this function. I just included the .js file.
由于我复制从其他网站(其中我想他们知道自己在说什么,因为它是一个网站关于JavaScript),并且它在FF工作的事实,阿贾克斯位,我不知道在哪里期待了。
Since i copied the ajax bit from another site (of which i assume they know what they are talking about because it is a site about javascript), and the fact that it does work in FF, I don't know where to look anymore.
请,谁可以帮我吗?
谢谢, 汉斯
语法({nmArray})
在支持ES6浏览器是一个快捷键 {nmArray:nmArray}
。 IE11不支持此功能(根据您所收到的错误),所以你必须将它重写成:
The syntax ({nmArray})
in a browser that supports ES6 is a shortcut for {nmArray: nmArray}
. IE11 doesn't support this feature (based on the error you're receiving), so you'll have to rewrite it as:
data: ({ nmArray: nmArray }),
在这里看到了一个例子:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_6
请注意,在这种情况下,你可以省略包装()
note that in this case you can omit the wrapping ()
data: { nmArray: nmArray },