I have this html code:
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<div class="container">
<div id="result" style="color:red"></div>
</div>
</body>
<script>
$(document).ready(function(){
$.ajax({
url: "https://api.github.com/users/Microsoft",
type: 'GET',
dataType: 'json',
success: function(res) {
$('#result').html(res)
}
});
})
</script>
Whenever I try to see the result on my browser it just shows an empty blank page.
I just need to return the API result and show it on html.
Any ideas?
$('#result').text(JSON.stringify(res))instead of your line. To analyse the issue, insertconsole.log( res );right before that line injecting the result into HTML element just to make sure this callback is ever invoked. And see the console for probably showing warning regarding CORS issue.<div>, but a<pre>might help with that, though it still might require to pretty-print the JSON as a string:$('#result').text(JSON.stringify(res, null, '\t'));.