IE8 支持属性或方法'forEach'
$('.tabs').tabs();
$('#search-consumables [data-ajax-call]').change(function() {
var $this = $(this),
settings = $this.data(),
$target = $(settings.target);
$.ajax({
type: 'GET',
url: 'index.php?route=module/quicklookup/' + settings.ajaxCall,
data: $this.closest('form').serializeArray(),
dataType: 'json',
success: function(data) {
var html = '';
$target.find(':not(.blank)').remove();
html = $target.html();
data.forEach(function(entry) {
html += '<option value="'+entry.id+'">'+entry.name+'</option>';
});
$target.html(html);
}
});
});
我试过了
$.each(data, function(entry) {
然后数据返回未定义,我缺少什么才能在 IE8 中运行它?
最佳答案
传递给 jQuery.each
回调的第一个参数是数组中值的索引;第二个参数是实际值。
尝试使用:
$.each(data, function(i, entry) {
// your code here
});
关于javascript - 脚本 438 : Object doesn't support property or method 'forEach' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15843834/