[英]how to show string data in html table on success call of ajax?
I got my data in sucess alert like: Kiran PaswanKiranpaswan@sbpbic.com8800134507
there is no key or id. 我在成功警报中得到了数据,例如: Kiran PaswanKiranpaswan@sbpbic.com8800134507
没有密钥或ID。
It returns only value or string. 它仅返回值或字符串。 Now I want this data in a table below the headers name email phone, but I have no idea how to do this. 现在,我希望在标题名称电子邮件电话下面的表格中获取此数据,但是我不知道如何执行此操作。 Here is my code of the ajax call: 这是我的ajax调用代码:
$.ajax({
type: 'POST',
url: '/assessment/omr-evaluation/post-omr-skill-based-career-test.aspx',
data: { row: data },
async: false,
success: function (data) {
var arr = new Array();
var names = data
arr = names.split('^');
$('#candy').html(arr);
alert(arr);
},
You can use : 您可以使用 :
var userTable = $('#user_table_id');
if(userTable == null || userTable.length == 0 ){
var table_html = "<table id='user_table_id'>";
table_html+= "<tr><td>Name</td><td>Email</td><td>Phone</td></tr>";
table_html+= "</table>";
$('#candy').html(table_html);
}
userTable = $('#user_table_id');
var newLine = $("<tr><td>"+arr[0]+"</td><td>"+arr[1]+"</td><td>"+arr[2]+"</td></tr>");
userTable.append(newLine );
The idea is to create a table structure if it doesn't exist yet . 这个想法是创建一个表结构( 如果还不存在的话) 。 And then add a row to that table 然后向该表添加一行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.