When I enter the url for instance, "www.example.com"
I get the return:
{
shh: {
id: 3730672,
name: "Shh",
profileIconId: 23,
summonerLevel: 2,
revisionDate: 1421646418000
}
}
I am trying to get all this data and displaying it on my website that is HTML. I tried researching and even tried the following code,
$.getJSON('www.example.com', function(data){
alert(data);
});
But it just displays nothing. Please help!
if your data callback is not empty you can try this :
{ shh: { id: 3730672, name: "Shh", profileIconId: 23, summonerLevel: 2, revisionDate: 1421646418000 } }
$.getJSON('www.example.com', function(data){
if(data){
var ssh = data.ssh;
var ssh_id = ssh.id;
var ssh_name = ssh.name;
$('.name').html(ssh_name);
$('.id').html(ssh_id);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<span class="name"></span> with id:<span class="id"></span>
</div>
Have you tried putting the breakpoint there and see what data contains? Also you should use data.d in alert instead of just data
$('#id').html(data.shh.id);
where you want to put your html id use and in response you will write data then write data or if you use result then you will use result