This script is pulling an img link, wich works fine so far, but I have no Idea how to return the link as an img.. Somebody help me!
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
var channel_name = 'justsmoki';
$.ajax({
url: 'https://api.twitch.tv/kraken/channels/' + channel_name,
type: 'GET',
dataType: 'jsonp',
contentType: 'application/json',
mimeType: 'application/vnd.twitchtv.v2+json',
success: function(json_result) {
$('#my_stream_logo').html(json_result.logo);
}
});
</script>
<span id="my_stream_logo"></span>
Try this...
var channel_name = 'justsmoki';
$.ajax({
url: 'https://api.twitch.tv/kraken/channels/' + channel_name,
type: 'GET',
dataType: 'jsonp',
contentType: 'application/json',
mimeType: 'application/vnd.twitchtv.v2+json',
success: function(json_result) {
$('#img').attr("src",json_result.logo);
}
});
Change span
to img
.
<img id="img" />
Here's the fiddle.
In your success callback, you want to set the html of your element. Replace this...
success: function(json_result) {
$('#my_stream_logo').html(json_result.logo);
}
With this...
success: function(json_result) {
$('#my_stream_logo').html("<img src='"+json_result.logo+"'>")
}