最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jquery ajax加载数据前台渲染方式 不用for遍历的方法
时间:2022-06-25 15:49:59 编辑:袖梨 来源:一聚教程网
如下所示:
var provinces = res.res;
var html = [];
var option_select='';
var tpl = '';
html.push(option_select);
$.each(provinces, function (i, n) {
html.push(tpl.format(n.name, n.id));
});
//alert(html.join());
$('#class').html(html.join(''));
function getXueke() { var gradeId = $('#grade_id').val(); if (gradeId == '') { $('#textbook_id').html(''); return; } $.get('index.php?m=Home&c=ClassList&a=getgradesandCourse', { 'grade_id': gradeId }, function (res) { var options = []; $.each(res, function (index, item) { options.push(''.format(item.id, item.course_name)); }); if (options.length > 0) { $('#textbook_id').html(options.join('')); } else { $('#textbook_id').html(''); } }) }
相关文章
- 价格跟踪交易-价格跟踪交易软件 04-25
- 碧蓝航线使用要注意什么 04-25
- 明日之后苹果能做什么食物攻略 04-25
- 以闪亮之名浅栗捏脸数据id攻略 04-25
- 逆水寒手游春归学堂奇遇如何完成 04-25
- 明日之后二层别墅建造蓝图攻略 04-25