I'm getting a json api back from my javascript request. I able to print the output to console and it looks properly formatted eg
{
"id": "1",
"name": "John"
}
but when I print to html page. it looks like this
'{"id": "1", "name": "john"}'
here my javascript file
$(function() {
//variables
var functionName = 'getQuotes';
function LoadData() {
$.get("http://localhost/quoteapi/api.php?function="+functionName+"&jsonCallback=?", function(data) {
// console.log(data);
jsonstr = data.substring(2, data.length-1)
console.log(jsonstr);
var jsonPretty = JSON.stringify(jsonstr,null,6);
});
}
LoadData();
});
and I want to print to a <p>
tag with id of "quote"
<p id="quote"></p>
any help appreciated