KATRIN1786492
а в чем проблема?
<div id="data"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function () {
var renderData = function(){
$.getJSON("https://api.icndb.com/jokes/random/10", function(data){
console.log(data) // просто выводим в консоль полученный Json
});
}
renderData();
var my_getJSON = function(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
resolve(xhr.response);
} else {
reject(status);
}
};
xhr.send();
});
};
var i=0;
my_getJSON('https://api.icndb.com/jokes/random/10').then(
function(data) { var end=data.value.length;var datum=document.getElementById("data");
for(i=0;i<end;i++) {datum.innerHTML += "<br>"+i+")"+data.value[i].joke;}; }, // resolve
function(status) {alert('Something went wrong.');} // reject
);
})
</script>