我在网站上的IE 11中有一个奇怪的行为......我在这个片段上收到控制台错误
function loadBasket (updated = false, buttonID = -1) {
$.ajax({
type: 'post',
url: azr_TemplateDir+'/ajax/page-basket.ajax.php',
success: function (data) {
$('.ajax-basket').html(data);
azrBinds();
},
complete: function (data) {
if(updated && buttonID >= 0) {
var button = $('div[data-buttonid="'+buttonID+'"]');
button.addClass('updated');
}
},
error : function(jqxhr,textStatus,error){
console.log(textStatus + ", " + error);
}
});
}
我的IE 11说它想在第1行第30列有一个')',但是在等号后面就是这样...... Safari,Firefox,Chrome和Edge都没有显示此错误。
有人有类似的问题吗?我很乐意为每一个帮助
由于
答案 0 :(得分:1)
那是因为IE 11不支持默认值。
function loadBasket (updated, buttonID) {
updated = typeof updated === "undefined" ? false : updated;
buttonID = typeof buttonID === "undefined" ? -1 : buttonID;
// ...
答案 1 :(得分:1)
IE不支持默认参数。
请改用此结构:
function loadBasket (updated, buttonID) {
updated = typeof updated !== 'undefined' ? updated : false;
buttonID = typeof buttonID !== 'undefined' ? buttonID : -1;
答案 2 :(得分:1)
IE不支持函数中的默认参数。
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Default_parameters
您必须手动编写默认值,例如:
for(int i=0;i<n;i++) {
for(int j=1; j<n; j*=5) ...
this is Big-theta(logn) with base 5 since it is multiplied by 5?