javascript - Show Image from JSON data? -


the json url http://api.bfhstats.com/api/playerinfo?plat=pc&name=1april&output=js

on line 16 contains part "imglarge" i'm trying show image on website. when parse data website showing string, not actual image.

here's code have:

$("#playerstuff").submit(function() {     $.ajax({         type: "get",          url: 'http://api.bfhstats.com/api/playerinfo?plat=' + document.getelementbyid("platform").value +'&name=' + document.getelementbyid("playername").value,           //datatype : "json",         success: function(data)         {             document.getelementbyid("playerrank").innerhtml = 'gamingstats.ga/' +data["player"]["rank"].imglarge;                             $("#formpanel").hide();                             $("#dataret").show();         }     });     return false; }); 

the output of url gamingstats.ga/bfh/ranks/r57.png not actual image.

change line ...

document.getelementbyid("playerrank").innerhtml = 'gamingstats.ga/' +data["player"]["rank"].imglarge; 

to ...

document.getelementbyid("playerrank").innerhtml = '<img src="http://gamingstats.ga/' +data["player"]["rank"].imglarge + '" />'; 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -