This is my first time coding Ajax, When i try to use this code which i basicly made my self nothing happens. So i was wondering if someone could help me to fix this.
JS & AJAX code:
<script type="text/javascript">
function loadsteamimage(imgid, steamid) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
document.getElementById(imgid).src = xmlhttp.getElementsByTagName("avatarMedium");
}
}
xmlhttp.open("GET","http://steamcommunity.com/profiles/" + steamid + "/?xml=1",true);
xmlhttp.send();
}
</script>
PHP code:
$steamid = "STEAM_0:1:55";
$parts = explode( ":", str_ireplace( "STEAM_0:", "", $steamid ) );
$friendid = bcadd( bcmul( $parts[ 1 ], "2" ), bcadd( "76561197960265728", $parts[ 0 ] ) );
$imgid = "testimg";
echo "<img src='images/noimage.png' id='testimg' onFinish='loadsteamimage($imgid,$friendid);'/>";
It would help me alot if someone could fix this code!
Thank's for taking your time to read & trying to help!