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 11-17-2008, 05:36 AM   PM User | #1
primefalcon
Regular Coder

 
primefalcon's Avatar
 
Join Date: Aug 2008
Location: /home/primefalcon/
Posts: 678
Thanks: 8
Thanked 39 Times in 39 Posts
primefalcon is an unknown quantity at this point
Ajax append

I have the following script that returns a simple php echo from a php script echo date("H:i:s"); to be precise, which is working fine.

what I want to know how to do though, is how to append date instead of replacing it

for example instead of just replacing

data

with

new data

how to make it add the new data to the old like old data, new data

and I'm not sure how to do this, can someone help please


here's the script

Code:
<html><head>
<title>Ajax test</title>
<script langauge="JavaScript">
var request = null;


function createRequest()
		{
			try
				{
					request = new XMLHttpRequest();
				} 
					catch(trymicrosoft)
						{
							try
								{
									request = new ActiveXObject("Msxml2.XMLHTTP");
								}
									catch(othermicrosoft)
										{
											try
												{
													request = new ActiveXObject("Microsoft.XMLHTTP");
												}
													catch(failed)
														{
															request = null;
														}
										}
																			
					
						}
						

						
											

						
			
							
			}</script>
</head><body>
<script langauge="JavaScript">


function updatePage()
				{
					if(request.readyState == 4)
						{
							var newData = request.responseText;
							document.getElementById("pagedisplay").innerHTML = newData;

							
						}
					
				}

function main()
	{
		createRequest();
		var serverurl = "http://localhost/ajaxtest/server.php";
		request.open("GET", serverurl, true);
		request.onreadystatechange = updatePage;
		request.send(null);
		setTimeout('main()', 1);

	}

setTimeout('main()', 250);

</script>
<div id="pagedisplay"></div>



</body></html>

Last edited by primefalcon; 11-17-2008 at 05:56 AM..
primefalcon is offline   Reply With Quote
Old 11-17-2008, 05:56 AM   PM User | #2
primefalcon
Regular Coder

 
primefalcon's Avatar
 
Join Date: Aug 2008
Location: /home/primefalcon/
Posts: 678
Thanks: 8
Thanked 39 Times in 39 Posts
primefalcon is an unknown quantity at this point
Nvm I worked it out myself

Code:
<html><head>
<title>Ajax test</title>
<script langauge="JavaScript">
var request = null;


function createRequest()
		{
			try
				{
					request = new XMLHttpRequest();
				} 
					catch(trymicrosoft)
						{
							try
								{
									request = new ActiveXObject("Msxml2.XMLHTTP");
								}
									catch(othermicrosoft)
										{
											try
												{
													request = new ActiveXObject("Microsoft.XMLHTTP");
												}
													catch(failed)
														{
															request = null;
														}
										}
																			
					
						}
						

						
											

						
			
							
			}</script>
</head><body>
<script langauge="JavaScript">


function updatePage()
				{
					if(request.readyState == 4)
						{
							var newData = request.responseText;
							var olddata = document.getElementById("pagedisplay").innerHTML;
							var Display = olddata + "<br />" +newData;
							document.getElementById("pagedisplay").innerHTML = Display;
							
							
						}
					
				}

function main()
	{
		createRequest();
		var serverurl = "http://localhost/ajaxtest/server.php";
		request.open("GET", serverurl, true);
		request.onreadystatechange = updatePage;
		request.send(null);
		setTimeout('main()', 500);

	}

setTimeout('main()', 250);

</script>
<div id="pagedisplay"></div>



</body></html>
primefalcon 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 05:25 PM.


Advertisement
Log in to turn off these ads.