Whats wrong with this? (Ajax)

This is a discussion on "Whats wrong with this? (Ajax)" within the JavaScript Forum section. This forum, and the thread "Whats wrong with this? (Ajax) are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack (1) Thread Tools
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old May 24th, 2006, 18:51
New Member
Join Date: May 2006
Age: 17
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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: Select all
<!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: Select all
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):
PHP: Select all

 <?php 
    $time 
date("d/m/y - s"); 
     
    echo 
$time
     
?>
Thanks in advance

Last edited by php_coder; May 25th, 2006 at 18:31.
Reply With Quote

  #2 (permalink)  
Old May 24th, 2006, 20:48
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
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 - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
Reply

Tags
wrong, ajax

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats wrong? Bradfordp26 Web Page Design 11 Apr 5th, 2008 10:14
whats wrong with these 2 ? batman13 JavaScript Forum 0 May 11th, 2007 19:29
Whats wrong with this? MaccGaz Other Programming Languages 1 Nov 4th, 2006 21:12
Whats wrong with tables and why css mrnthere Web Page Design 7 Mar 16th, 2006 23:38
Whats wrong with this? TheShadow Classic ASP 5 May 26th, 2005 12:55


All times are GMT. The time now is 19:38.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43