[英]javascript Ajax SCRIPT1003: Expected ':' in IE 11
var url="tabla.php";
$.ajax({
type: "POST",
url:url,
data:{place,names,repor},
success: function(datos){
$('#tabla').html(datos);
}
This code works in Chrome but in IE 11 returns the error SCRIPT1003: Expected ':'
on line 5. I'd really appreciate any help. 此代码适用于Chrome,但在IE 11中返回错误
SCRIPT1003: Expected ':'
第5行SCRIPT1003: Expected ':'
。我真的很感激任何帮助。
Note: place
and names
are arrays that are previously defined, and repor
is also a previously defined variable. 注意:
place
和names
是先前定义的数组, repor
也是先前定义的变量。
Usually objects in javascript are initialized as key value pairs, so data should probably be initialized like 通常javascript中的对象被初始化为键值对,因此数据应该初始化为
data:{ place : place, names : names, report : report }
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer 请参阅https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer
In ECMAScript 2015 it seems you can omit the key part in certain situations, which is why it works on chrome. 在ECMAScript 2015中,似乎你可以省略某些情况下的关键部分,这就是它适用于chrome的原因。
I had the SCRIPT1003: Expected ':' error as well in IE 11 (and my code worked fine in Chrome & FireFox). 我在IE 11中有SCRIPT1003:预期':'错误(我的代码在Chrome和FireFox中运行良好)。 If someone uses Knockoutjs and encounters this, watch out for the syntax when stating functions in your view model:
如果有人使用Knockoutjs并遇到此问题,请在查看视图模型中的函数时注意语法:
var viewModel = {
property1: "",
functionWorksInAllBrowsers: function (arg1, arg2) {
// ...
},
functionThrowsErrorInInternetExplorer11(arg1, arg2) {
//...
}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.