EchoFool Posted August 21, 2009 Share Posted August 21, 2009 This line is causing this error: Line: document.getElementById('gamelist').innerHTML = gameslist; Error: unexpected end of XML source Im not following what this is trying to tell me the problem is .. ? Quote Link to comment Share on other sites More sharing options...
haku Posted August 21, 2009 Share Posted August 21, 2009 Show us a bunch of lines before that as well. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted August 21, 2009 Author Share Posted August 21, 2009 Ok its a little complex so bare with me : PHP Script: (load certain data for list) root/subfolder <script language="javascript"> function games(){ var url = document.location.href; var xend = url.lastIndexOf("/") + 1; var base_url = url.substring(0, xend); // var base_url = '../pokerbackup/includes/'; // thisurl = base_url + 'live_games.php'; //document.write(base_url); thisurl = base_url + 'live_gamestest.php'; checkloadfile(thisurl, "js"); setTimeout("games()", 3000); // games() is using an onload on the body line in this script below } </script> <body bgcolor="#000000" text="#CCCCCC" onLoad="games();"> <div id="gamelist" style="border : solid 0px padding : 1px; width : 100%; height : 365px; overflow : auto; "> </div ><br> <?php $tableq = mysql_query("select p1ID, p2ID,tablename,tablelimit,tabletype,hand,tablelow from table order by tablelimit asc ") or die(mysql_error()); while($tabler = mysql_fetch_array($tableq)){ $i = 1; $x=0; while($i < 11){ if($tabler['p'.$i.'ID'] != '' OR $tabler['p'.$i.'ID']< 1){ $x++; } $i++; } $tableplayers = $x.'/10'; $tablestatus = (($tabler['hand'] == '')? 'New Game' : 'Playing'); $tabletype = (($tabler['tabletype'] == 't')? 'Tournament' : 'Sit \'n Go'); } ?> JS script: (when call list all chat rooms and display them in div id "gamelist" root/subfolder/includes/ <script language='javascript'> <?php include($_SERVER['DOCUMENT_ROOT'].'/css/includes/bconnect45/connect.php'); include($_SERVER['DOCUMENT_ROOT'].'/css/includes/afunctions23/functions.php'); // require('gen_inc2.php'); ?> var gameslist = '<table border="0" cellspacing="0" cellpadding="3" width="100%" class="smllfontwhite">'; <?php $tableq = mysql_query("select gameID, p1ID, p2ID,p3ID, p1pot, p2pot, p3pot, tablename,tablelimit ,tabletype,hand,tablelow, pot from poker order by tablelimit asc ") or die(mysql_error()); while($tabler = mysql_fetch_array($tableq)){ //get variables etc ?> gameslist += '<tr onMouseOver="this.bgColor = \'#330000\'; this.style.color = \'#FFFFFF\';" onMouseOut="this.bgColor = \'\'; this.style.color = \'#FFFFFF\';" onClick="selectgame(\'lobby.php?gameID=<? echo $gID; ?>\');" class="hand">'; gameslist += '<td class="smllfontwhite" width="120"><?php echo $tablename; ?></td><td width="50" align="center" class="smllfontwhite"><?php echo $tableplayers; ?></td><td class="smllfontwhite" width="80" align="center"><?php echo $tabletype; ?></td><td class="smllfontwhite" width="90" align="center"><?php echo $buyin; ?></td><td class="smllfontwhite" width="90" align="center"><?php echo $SB; ?></td><td class="smllfontwhite" width="90" align="center"><?php echo $BB; ?></td><td class="smllfontwhite" width="80" align="center"><?php echo $tablestatus; ?></td></tr>'; <?php } ?> gameslist += '</table>'; document.getElementById('gamelist').innerHTML = gameslist; I don't know how to make javascript colourful like php does in these code tags sorry.. the basic idea is .. in body it onloads (games()) function in the JS in the first script. This calls a second js script which loads list of rooms and does it every 3 seconds to keep the list "live" as it were without refresh required... but as you know it errors.. hope you can help. It is meant to display the content in the div on the first script with the id of gamelist Quote Link to comment Share on other sites More sharing options...
haku Posted August 21, 2009 Share Posted August 21, 2009 Can you show us the output of that? The php just gets in the way, as it has nothing to do with the javascript. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted August 21, 2009 Author Share Posted August 21, 2009 There is no output thats the problem... the only output is basically what is loaded outside the javascript.. and i did check the while loop it is loading 1 row, so it should load one load from the javascript. But the page source shows: <div id="gamelist" style="border : solid 0px padding : 1px; width : 100%; height : 365px; overflow : auto; "> </div > Thats it but firebug addon on FF shows: unexpected end of XML source [break on this error] document.getElementById('gamelist').innerHTML = gameslist; Quote Link to comment Share on other sites More sharing options...
haku Posted August 21, 2009 Share Posted August 21, 2009 No, I mean run your scripts that have the php in them, and show us the output. You showed a bunch of code with php in it. The php is irrelevant - only the output of the php matters. So if you run the php script, then view the source, we can see the raw javascript code. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted August 21, 2009 Author Share Posted August 21, 2009 Argh wait i got it working on a much easier script using: <script type="text/javascript"> var auto_refresh = setInterval( function () { $('#load_tweets').load('live_gamestest.php')..fadeIn("fast"); }, 1000); // refresh every 1000 milliseconds </script> <div id="load_tweets"> </div> Now its basically just like having a php include with output ! Unless you know a simpler way? Its working so far. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.