JSON data table does not upload?
Clash Royale CLAN TAG#URR8PPP
JSON data table does not upload?
I am trying to pull JSON file and then put in a data table but it is not working and I've looked up similar codes but none work. any help?
<script>
$.getJSON("file.json", function(data)
console.log("just checking");
var items=;
$.each(data, function(key, val)
console.log("double check");
items.push("<tr>");
items.push("<td id='"+key+"'>"+val.system+"</td>");
items.push("<td id='"+key+"'>"+val.status+"</td>");
items.push("</tr>");
items.push("<tr>");
items.push("<td id='"+key+"''>"+val.system+"</td>");
items.push("<td id='"+key+"''>"+val.status+"</td>");
items.push("</tr>");
items.push("<tr>");
items.push("<td id='"+key+"'>"+val.system+"</td>");
items.push("<td id='"+key+"'>"+val.status+"</td>");
items.push("</tr>");
);
$('<tbody/>', html: items.join('')).append('table');
console.log("triple check");
);
yes, i have to be logged in but even when i am logged in, it only uploads the <th> but not the <td>
– Karina Turtle
Aug 6 at 2:18
$('<tbody/>', html: items.join('')).append('table');
, this will never work– Leo
Aug 6 at 2:19
$('<tbody/>', html: items.join('')).append('table');
thats exacly how they have it on youtube. what is mission or how can i fix it?
– Karina Turtle
Aug 6 at 2:22
you really should review your code rather than copy/pasting it...
items.push("<td id='"+key+"''>"+val.system+"</td>");
you are adding two single-quotes when concatenating the cell ID and that will break your HTML– Leo
Aug 6 at 2:24
items.push("<td id='"+key+"''>"+val.system+"</td>");
1 Answer
1
Here you go with the solution
$.getJSON("file.json", function(data)
console.log("just checking");
var items=;
$.each(data, function(key, val)
console.log("double check");
items.push("<tr>");
items.push("<td id='"+key+"'>"+val.system+"</td>");
items.push("<td id='"+key+"'>"+val.status+"</td>");
items.push("</tr>");
items.push("<tr>");
items.push("<td id='"+key+"''>"+val.system+"</td>");
items.push("<td id='"+key+"''>"+val.status+"</td>");
items.push("</tr>");
items.push("<tr>");
items.push("<td id='"+key+"'>"+val.system+"</td>");
items.push("<td id='"+key+"'>"+val.status+"</td>");
items.push("</tr>");
);
var joinedItems = items.join('');
$('table').append(joinedItems);
console.log("triple check");
);
Hope this will help you.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Are you providing credentials for that url? Just tried opening it and it says you have to be logged in and response status is 403 which won't go to the success callback
– charlietfl
Aug 6 at 2:15