Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-18-2011, 06:04 PM   PM User | #1
Darkfortune
New to the CF scene

 
Join Date: Mar 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Darkfortune is an unknown quantity at this point
Exclamation New to ajax...

Hi!
I posted this on JavaScript but they didn't answer...
Here's my code, It doesn't work but it needs to load a php file every 0.5 seconds and then put it in a div called content.
I'm new to Ajax & JavaScript so it is a bunch of snippets merged together =/
Code:
function refresh()
{
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		document.getElementById("content").innerHTML=xmlhttp.responseText;
		}
	  }
	xmlhttp.open('GET','chat.php,true');
	xmlhttp.send();
	setTimeout('refresh()', 500);
Darkfortune is offline   Reply With Quote
Old 03-19-2011, 06:47 AM   PM User | #2
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
"They" are pretty much the same people that will answer you here.

And the reason "they" didn't answer in your other thread is twofold:

First, it has only been an hour since you opened that other thread (which I deleted, because crossposting violates forum rules). Since you don't pay any of the people here to do your work, you will have to wait until someone chooses to invest their free time in helping you.

Second, "My code doesn't work and I don't know how to fix it" is a really bad incentive for anyone to help you. This is a place for professional exchange, which gives people willing to learn the opportunity to benefit from collective experience. It's not a free coding service.
venegal is offline   Reply With Quote
Old 03-19-2011, 07:05 AM   PM User | #3
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Quote:
Originally Posted by Darkfortune View Post
It doesn't work but it needs to load a php file every 0.5 seconds and then put it in a div called content.
1) Your problem could be with the code in chat.php

2) you have a syntax error in
xmlhttp.open('GET','chat.php,true');

This tute might help you

Last edited by bullant; 03-19-2011 at 07:08 AM..
bullant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:43 AM.


Advertisement
Log in to turn off these ads.