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
});