js 拼接ajax请求回来的值,渲染到页面表格上

html部分

<table class="table table-hover table-bordered">
	<thead class="thead">
		<tr>
			<th>A</th>
			<th>B</th>
			<th>C</th>
			<th>D</th>
			<th>E</th>
		</tr>
	</thead>
	<tbody class="tbody" id="tbody">
	</tbody>
</table>

js部分

$.ajax({
	type: "method",
		url: "url",
		data: "data",
		dataType: "dataType",
		success: function (result) {
		$('#tbody').empty();
		var html = ''
		$.each(result, function (index, value) {
			html += "";
			html += "" + value.a+ "";
			html += "" + value.b+ "";
			html += "" + value.c+ "";
			html += "" + value.d+ "";
			html += "" + value.e+ "";
			html += "";
		});
		$('#tbody').append(html);
		}
	});

你可能感兴趣的:(JavaScript)