use*_*678 4 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.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);
}
});
});
Run Code Online (Sandbox Code Playgroud)
我试过了
$.each(data, function(entry) {
Run Code Online (Sandbox Code Playgroud)
然后数据返回undefined,我在IE8中使用了什么?
传递给jQuery.each
回调的第一个参数是数组中值的索引; 第二个参数是实际值.
尝试使用:
$.each(data, function(i, entry) {
// your code here
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5503 次 |
最近记录: |