[英]How to generate dynamic tables with jquery by receiving json response from php
我希望我的输出格式如下。 我的设计应如下。
我想帮助设计上面的方法。 请任何人都可以帮助我。 我存储rollno
在student
表和marks
的marks
表。 标记表包含对student rollno
的引用。
如何使用php将json值发送到jquery ajax并将响应分配给页面?
或者,如果您有任何其他方法来执行此操作。 请同意。 提前致谢。
试试吧,
$(function(){
$.ajax({
url:'getStudMarks.php',
data:{rollNo:'19GH24'},// get marks of student 19GH24
type:'POST',
success:function(data){
$('table tbody').html(data);
}
});
});
并在getStudMarks.php
页面返回您的数据,如,
<tr><td>C</td><td>90</td><td>98</td></tr>;
对于多个表,您需要提供table id
<table id="table-19GH24">
<thead>
....
</thead>
<tbody>....</tbody>
</table>
并且success callback
使用rollno
类的,
$('#table-19GH24 tbody').html(data);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.