admin管理员组文章数量:1390564
IE8 support property or method '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);
}
});
});
I have tried
$.each(data, function(entry) {
yet data then returns undefined, What am I missing to get this working in IE8?
IE8 support property or method '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);
}
});
});
I have tried
$.each(data, function(entry) {
yet data then returns undefined, What am I missing to get this working in IE8?
Share Improve this question asked Apr 5, 2013 at 21:23 user2250678user2250678 431 silver badge3 bronze badges 1-
data
is of the typeobject
which has no methodforEach()
– jmoerdyk Commented Apr 5, 2013 at 21:29
1 Answer
Reset to default 6The first argument passed to the jQuery.each
callback is the index of the value in the array; the second argument is the actual value.
Try using:
$.each(data, function(i, entry) {
// your code here
});
本文标签: javascriptSCRIPT438 Object doesn39t support property or method 39forEach39Stack Overflow
版权声明:本文标题:javascript - SCRIPT438: Object doesn't support property or method 'forEach' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744725563a2621942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论