How to populate html table with json object contents
up vote
0
down vote
favorite
I am returning a list in a ajax call the success function is written below.
My json has contents like {"1","ayesha","cs","Lahore"}.
function ShowData(data) {
var data = data.d;
var html = "";
if (data.length > 0) {
JObject = data;
console.log(JObject);
html = "<table id='tbl' class='TableGrid' width='100%' >";
html += "<thead><tr><th>StdId</th><th>Name</th><th>feild</th><th>City</th></thead><tbody> ";
for (var i = 0; i < JObject.length; i++) {
html += '<tr>';
html += ' <td align="left" >' + JObject[i] + '</td>';
html += '</tr>';
}
html += "</tbody> </table>";
}
How should i display the contents?
asp.net json ajax html-table
add a comment |
up vote
0
down vote
favorite
I am returning a list in a ajax call the success function is written below.
My json has contents like {"1","ayesha","cs","Lahore"}.
function ShowData(data) {
var data = data.d;
var html = "";
if (data.length > 0) {
JObject = data;
console.log(JObject);
html = "<table id='tbl' class='TableGrid' width='100%' >";
html += "<thead><tr><th>StdId</th><th>Name</th><th>feild</th><th>City</th></thead><tbody> ";
for (var i = 0; i < JObject.length; i++) {
html += '<tr>';
html += ' <td align="left" >' + JObject[i] + '</td>';
html += '</tr>';
}
html += "</tbody> </table>";
}
How should i display the contents?
asp.net json ajax html-table
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am returning a list in a ajax call the success function is written below.
My json has contents like {"1","ayesha","cs","Lahore"}.
function ShowData(data) {
var data = data.d;
var html = "";
if (data.length > 0) {
JObject = data;
console.log(JObject);
html = "<table id='tbl' class='TableGrid' width='100%' >";
html += "<thead><tr><th>StdId</th><th>Name</th><th>feild</th><th>City</th></thead><tbody> ";
for (var i = 0; i < JObject.length; i++) {
html += '<tr>';
html += ' <td align="left" >' + JObject[i] + '</td>';
html += '</tr>';
}
html += "</tbody> </table>";
}
How should i display the contents?
asp.net json ajax html-table
I am returning a list in a ajax call the success function is written below.
My json has contents like {"1","ayesha","cs","Lahore"}.
function ShowData(data) {
var data = data.d;
var html = "";
if (data.length > 0) {
JObject = data;
console.log(JObject);
html = "<table id='tbl' class='TableGrid' width='100%' >";
html += "<thead><tr><th>StdId</th><th>Name</th><th>feild</th><th>City</th></thead><tbody> ";
for (var i = 0; i < JObject.length; i++) {
html += '<tr>';
html += ' <td align="left" >' + JObject[i] + '</td>';
html += '</tr>';
}
html += "</tbody> </table>";
}
How should i display the contents?
asp.net json ajax html-table
asp.net json ajax html-table
asked Nov 8 at 9:27
Ayesha1234
62
62
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
Use bellow script can help to create table
- var table = document.createElement("table");
- var thead = document.createElement("thead");
- var tr = document.createElement("tr");
- var th = document.createElement("th");
- var td = document.createElement("td");
- table.appendChild(thread).appendChild(th);
- table.appendChild(tr).appendChild(td)
New contributor
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
Use the .innerHTML to insert your table inside your template.
DOCS: https://www.w3schools.com/jsref/prop_html_innerhtml.asp
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Use bellow script can help to create table
- var table = document.createElement("table");
- var thead = document.createElement("thead");
- var tr = document.createElement("tr");
- var th = document.createElement("th");
- var td = document.createElement("td");
- table.appendChild(thread).appendChild(th);
- table.appendChild(tr).appendChild(td)
New contributor
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
Use bellow script can help to create table
- var table = document.createElement("table");
- var thead = document.createElement("thead");
- var tr = document.createElement("tr");
- var th = document.createElement("th");
- var td = document.createElement("td");
- table.appendChild(thread).appendChild(th);
- table.appendChild(tr).appendChild(td)
New contributor
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
up vote
0
down vote
Use bellow script can help to create table
- var table = document.createElement("table");
- var thead = document.createElement("thead");
- var tr = document.createElement("tr");
- var th = document.createElement("th");
- var td = document.createElement("td");
- table.appendChild(thread).appendChild(th);
- table.appendChild(tr).appendChild(td)
New contributor
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Use bellow script can help to create table
- var table = document.createElement("table");
- var thead = document.createElement("thead");
- var tr = document.createElement("tr");
- var th = document.createElement("th");
- var td = document.createElement("td");
- table.appendChild(thread).appendChild(th);
- table.appendChild(tr).appendChild(td)
New contributor
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered Nov 8 at 9:35
He Shuang
1
1
New contributor
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
He Shuang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
up vote
0
down vote
Use the .innerHTML to insert your table inside your template.
DOCS: https://www.w3schools.com/jsref/prop_html_innerhtml.asp
add a comment |
up vote
0
down vote
Use the .innerHTML to insert your table inside your template.
DOCS: https://www.w3schools.com/jsref/prop_html_innerhtml.asp
add a comment |
up vote
0
down vote
up vote
0
down vote
Use the .innerHTML to insert your table inside your template.
DOCS: https://www.w3schools.com/jsref/prop_html_innerhtml.asp
Use the .innerHTML to insert your table inside your template.
DOCS: https://www.w3schools.com/jsref/prop_html_innerhtml.asp
answered Nov 8 at 9:36
Leonardo Minati
136111
136111
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204804%2fhow-to-populate-html-table-with-json-object-contents%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password