代码有效,但它一直给我这个错误控制台:未捕获的SyntaxError:意外的令牌)
检查我的代码的最后一行是我收到错误的地方。提前谢谢。
function change_type(itemID) {
window.location = "/store/basket.cfm?mode=select&itemID=" + itemID;
}
// gets pertinent mediums for a year...
function change_medium_list(award_year) {
// clear previous contents...
$("select#medium_name").empty();
//console.log('cleared existing mediums');
// do a JSON get......
$.getJSON("_medium_list_by_year.cfm", {
award_year: award_year,
ajax: 'true'
}, function(p) {
var jsonList = (p);
//alert(jsonList);
var listItems = "";
for (var i = 0; i < jsonList.Table.length; i++) {
listItems += "<option value='" + jsonList.Table[i].optionValue + "'>" + jsonList.Table[i].optionDisplay + "</option>";
}
// Write the new values in...
$("#medium_name").change(listItems);
//console.log('written mediums');
// this doesn't seem to refresg the content...
// $('.selectpicker').selectpicker('render');
$('.selectpicker').on('change', function() {
var selected = $(this).find("option:selected").val();
alert(selected);
});
});
}); **// here is where I get the error. but if it change it to }; my code doesnt work.**
答案 0 :(得分:2)
删除尾随括号,因此最后一行看起来像这样
}; //here is where I get the error. but if it change it to }; my code doesnt work.**
答案 1 :(得分:0)
在第二个函数后删除分支和分号。两者都不需要。
);