javascript - SCRIPT438: Object doesn't support property or method 'forEach' -


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 returns undefined, missing working in ie8?

the first argument passed jquery.each callback index of value in array; second argument actual value.

try using:

$.each(data, function(i, entry) {     // code here }); 

Comments