Click here to Skip to main content
15,885,216 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: send the more than one client and server program in java with source code Pin
Richard MacCutchan12-Sep-11 2:18
mveRichard MacCutchan12-Sep-11 2:18 
QuestionRegular expression Pin
Phrone7-Sep-11 9:21
Phrone7-Sep-11 9:21 
AnswerRe: Regular expression Pin
Firo Atrum Ventus7-Sep-11 17:46
Firo Atrum Ventus7-Sep-11 17:46 
GeneralRe: Regular expression Pin
Phrone7-Sep-11 20:22
Phrone7-Sep-11 20:22 
GeneralRe: Regular expression Pin
Member 215126112-Sep-11 9:26
Member 215126112-Sep-11 9:26 
QuestionJavascript Form Validation Pin
starr0077-Sep-11 9:09
starr0077-Sep-11 9:09 
AnswerRe: Javascript Form Validation Pin
Peter_in_27807-Sep-11 21:59
professionalPeter_in_27807-Sep-11 21:59 
QuestionHelp with Ajax Pin
ShenDraeg7-Sep-11 8:56
ShenDraeg7-Sep-11 8:56 
I'm working on a dice-roller that's an ugly mix of PHP, JavaScript, and whatever else I need in order to make it work. The roller itself works fine, but I decided to get a little fancy with it for the sake of the person that I'm doing this for, and I tried to add logging to it, and breaking down the logs based on what "game" the user is playing. The issue is that I want to have the logs update themselves after x seconds. PHP clearly can't handle this, and my understanding is that JavaScript can't do it by itself, so I have attempted to learn enough Ajax to piece everything together. Here is what I've managed to put together:

JavaScript
<script type='text/javascript'>

// refresh every 30 seconds
var timer = 10;
var game_id = '$g';

var updateLogs = function()
{

	var url = 'backend/timed-script.php?g=' + game_id + '&randval=' + Math.random();
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open('GET',url,'TRUE');
	xmlhttp.send();

	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			document.getElementById('log_box').innerhtml = xmlhttp.responstText;
		}
	}
}

setInterval(updateLogs, timer*1000);

</script>


I've thrown an alert() inside updateLogs to make sure that setInterval isn't failing, and that works. The issue is that the
isn't populating like it should. I know that timed-script.php works (since pasting the URL in my address bar brings the page up with the appropriate data). Can someone tell me what I'm doing wrong here?

Thanks

AnswerRe: Help with Ajax Pin
Morgs Morgan7-Sep-11 21:04
Morgs Morgan7-Sep-11 21:04 
GeneralRe: Help with Ajax Pin
ShenDraeg8-Sep-11 3:56
ShenDraeg8-Sep-11 3:56 
GeneralRe: Help with Ajax Pin
Morgs Morgan8-Sep-11 4:29
Morgs Morgan8-Sep-11 4:29 
GeneralRe: Help with Ajax Pin
ShenDraeg8-Sep-11 6:40
ShenDraeg8-Sep-11 6:40 
GeneralRe: Help with Ajax Pin
ShenDraeg16-Sep-11 9:16
ShenDraeg16-Sep-11 9:16 
AnswerRe: Help with Ajax Pin
ShenDraeg13-Sep-11 9:09
ShenDraeg13-Sep-11 9:09 
Questionproblem with Joomla template - jQuery conflict mootols Pin
nikolay1006-Sep-11 0:04
nikolay1006-Sep-11 0:04 
AnswerRe: problem with Joomla template - jQuery conflict mootols Pin
nikolay1008-Sep-11 19:44
nikolay1008-Sep-11 19:44 
GeneralRe: problem with Joomla template - jQuery conflict mootols Pin
Firo Atrum Ventus8-Sep-11 20:09
Firo Atrum Ventus8-Sep-11 20:09 
Questionsimple javascrpt: checkbox Pin
AndyInUK2-Sep-11 7:13
AndyInUK2-Sep-11 7:13 
AnswerRe: simple javascrpt: checkbox Pin
Evan Gallup3-Sep-11 19:08
Evan Gallup3-Sep-11 19:08 
GeneralRe: simple javascrpt: checkbox Pin
AndyInUK5-Sep-11 5:43
AndyInUK5-Sep-11 5:43 
GeneralRe: simple javascrpt: checkbox Pin
Evan Gallup5-Sep-11 6:53
Evan Gallup5-Sep-11 6:53 
QuestionXML and Javascript Pin
Member 820418431-Aug-11 19:26
Member 820418431-Aug-11 19:26 
QuestionRe: XML and Javascript Pin
DaveAuld31-Aug-11 22:43
professionalDaveAuld31-Aug-11 22:43 
AnswerRe: XML and Javascript Pin
Evan Gallup3-Sep-11 19:39
Evan Gallup3-Sep-11 19:39 
Questioniphone style switch Pin
AndyInUK30-Aug-11 23:07
AndyInUK30-Aug-11 23:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.