A company that I am working with has an API for their Privacy Policy and Terms of Use. I need to create two different pages...one for the Privacy Policy and one for the Terms of Use. I'm pretty new at this, and I feel like I'm so close.
Here is the way that the JSON is received (with some edits to anonymize it):
{"code":200,"status":"Ok","data":
{"offset":0,"limit":20,"total":2,"target":"html_page","results":[
{
"id":"6",
"title":"Privacy Policy",
"description":"Privacy Policy",
"html":"HTML CODE BLAH BLAH",
"tags":["privacy"]
},
{
"id":"66",
"title":"License and TOU",
"description":"Terms of Use",
"html":"HTML CODE BLAH BLAH",
"tags":["terms"]
}]
}
}
Here's the code I'm using:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Privacy Policy</title>
</head>
<body>
<div id="placeholder"></div>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$.getJSON('http://externalurl.com', function(external) {
var output="<ul>";
for (var i in external.code.offset) {
output+="<li>" + external.html + "</li>";
}
output+="</ul>";
document.getElementById("placeholder").innerHTML=output;
});
</script>
</body>
</html>
It's just returning a blank page. What am I doing wrong?
$.getJSON('http://externalurl.com', function(external) {
var output = $("<ul />");
$.each(external.data.results, function(i, result) {
$('<li />', {text : result.html}).appendTo(output);
});
$('#placeholder').html(output);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With