Pergunta

I am currently running a jQuery/PHP code. In the PHP, I use a while loop to look in my MySQL for the persons login. If the code finds the user logged in in the database it displays a queue where it pulls each steam id, contacts steam api, retrieves each steam avatar and displays it on the widget. The jQuery executes a code that loads a certain div of the page every 10 seconds.

Everything works when you are clicked on to the page however, when you click off of the page in another tab you get an "Oh snap" error in Chrome. I tried the code in Mozilla and Internet Explorer and it got an error there as well. I originally thought that it was because it took longer than 10 seconds to connect to steam api but I tested it when I was not logged in so it was not contacting steam api but I was still getting the error.

jQuery:

<html>
  <head>
     <script type="text/javascript" src="jquery.js"></script>
     <script type="text/javascript">
          jQuery(function($){
             setInterval(function(){
             $('#header').load('button1.php');
             }, 10000);
          });
    </script>
   </head>
  <body>

PHP:

$result = mysqli_query($link, "SELECT text FROM names order by id limit 10");
$result2 = mysqli_query($link, "SELECT text FROM names order by id limit 10");
while($rows = mysqli_fetch_array($result))
{
   $name = $rows['text'];
   if($Steam64id == $name)
   {
      while($rowss = mysqli_fetch_array($result2))
      {
        $names = $rowss['text'];
        echo"<br>";
        include"avatar2.php";
      }
   }
   else
   {
   }
}

avatar2.php:

<?php
$response = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/? key=xxx&steamids={$names}&format=json";
$middle = (file_get_contents($response));
$json = json_decode($middle, true);
$a = $json['response']['players'][0]['avatarfull'];
$b = $json['response']['players'][0]['personaname'];
echo "<font size='2'>";
print_r($b);
echo "<br>";
echo"<img src='$a' alt=''height='42' width='42'>";
?>

Any help here would be great. This is my first time using Javascript besides a show/hide table. Thanks.

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top