iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack (1) Thread Tools
Old May 24th, 2006, 02:51 PM   1 links from elsewhere to this Post. Click to view. #1
New Member
 

Join Date: May 2006
Age: 18
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 php_coder is on a distinguished road
Whats wrong with this? (Ajax)

Well I'm just starting out with ajax, and tryed making the simplest thing to start off with. When you click the button, it shows the date and how many seconds has gone. This is what I've got so far.

HTML Page (ajax.html):
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Testing AJAX</title>
<script type="text/javascript" src="ajax.js"></script>
</head>
<body>
<input type="button" name="ajax" id="name" onkeyup="getTime()" value="Check Time">
<div id="outputMessage"></div>
</body>
</html>
JavaScript Page (ajax.js):
Code:
function createRequest () {
    try {
        request = new XMLHttpRequest ();
    } catch (trymicrosoft) {
    
    try {
        request = new ActiveXObjext("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
    
    try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
        
        request = null;
    }
    }
    }
    
    if (request == null)
    alert ("Error creating the request object!");
}
    
function getTime() {
    createRequest();
    var url = "http://www.jack-day.com/ajax.php";
    request.open("GET", url, true);
    onreadystatechange = processTime();
    request.send(null);
}

function processTime(){
	if (request.readyState==4 || request.readyState=="complete")
	{ 
		document.getElementById("outputMessage").innerHTML = request.responseText;
	}
}
PHP Page (ajax.php):
Code:
 <?php 
    $time 
date("d/m/y - s"); 
     
    echo 
$time
     
?>
Thanks in advance

Last edited by php_coder; May 25th, 2006 at 02:31 PM..
php_coder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 24th, 2006, 04:48 PM   #2
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,131
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
Re: Whats wrong with this? (Ajax)

Isnt time a reserved word? Maybe not, but it is in ASP and other languages.

Try changing the variable time, to something else.
__________________
Rob - Webforumz Founder

I am currently NOT available for SEO consultancy work

My Sites: Student Midwife Forum, Costa Luz Holiday Rentals
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
wrong , ajax


LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/javascript/6518-whats-wrong-with-this-ajax.htm
Posted By For Type Date
ajax php This thread Refback September 7th, 2006 05:18 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats wrong? Bradfordp26 HTML, XHTML and CSS 11 April 5th, 2008 06:14 AM
whats wrong with these 2 ? batman13 JavaScript 0 May 11th, 2007 03:29 PM
Whats wrong with this? MaccGaz Other Languages 1 November 4th, 2006 05:12 PM
Whats wrong with tables and why css mrnthere HTML, XHTML and CSS 7 March 16th, 2006 07:38 PM
Whats wrong with this? TheShadow Classic ASP 5 May 26th, 2005 08:55 AM


Search Engine Optimization by vBSEO 3.2.0 RC8