Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SCRIPT438:对象没有';t支持属性或方法';forEach&x27;_Javascript_Ajax_Json_Internet Explorer 8 - Fatal编程技术网

Javascript SCRIPT438:对象没有';t支持属性或方法';forEach&x27;

Javascript SCRIPT438:对象没有';t支持属性或方法';forEach&x27;,javascript,ajax,json,internet-explorer-8,Javascript,Ajax,Json,Internet Explorer 8,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

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

然而数据随后返回undefined(未定义),在IE8中,我缺少什么才能使其工作?

传递给
jQuery的第一个参数。每个
回调都是数组中值的索引;第二个参数是实际值

尝试使用:

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

数据
的类型为
对象
,该对象没有方法
forEach()
$.each(data, function(i, entry) {
    // your code here
});