Hello, i need to retrieve JSON DATA from url and write it to HTML table, but…in console is everything okay, but when i try to write it to HTML, it wrote only [object][object] etc…
My HTML code where i need to put data(table) is div “tabulka”:
<div id="data-show"></div>
<div id="data-celkem"></div>
<div id="tabulka" border="1">
</div>
</div>
</div>
</body>
</html>
and JAVASCRIPT CODE:
var data_array = [];
var root = 'http://192.168.2.238:57771/rest/control/getReleases';
$(document).ready(function () {
jQuery.support.cors = true;
$('#data-load').click(function () {
var showData = $('#data-show');
$("#loader").show();
$.ajax(
{
type: "POST",
url: root,
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
success: function (data) {
console.log(data);
/*
$.each(data, function (i, item) {
$("#tabulka").html('<div>' + data + '</div>');
});
*/
data.forEach(myFunction);
function myFunction (item, index) {
for( var key in item ) {
$('#tabulka').append('data-key', JSON.stringify(data));
}
}
$( function() {
$( "#dialog" ).slideDown(500);
$( "#dialog" ).fadeOut(5000);
$("#loader").hide();
});
}
});
});
});