TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 02-24-2008, 02:31 PM   #1 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 132
Thanks: 3
Gareth is on a distinguished road
Default AJAX - undefined?

Hi

I recently delved into the world of AJAX, but can't seem to get it working!

The actual displaying of a message in a div without loading is working; but there's something incorrect in my definition of fields.

I am using JQuery; with this javascript:

Code:
<script type="text/javascript">

	function request(){
	
		$.ajax({
		    type: "POST",
		    url: "insert2.php",
		    data: "username=" + $("#username").value,           
		    success: function(html){
		        $("#response").html(html);
		    }
		});
		
		}
	
	</script>
and then the form is thus:

Code:
				<form method="post" action="">

					<table class="formRegistration">
						<tr>
							<td>Username:</td>
							<td><input name="username" id="username" type="text" value="" maxlength="20" /></td>
						</tr>
						
						<tr>
							<td></td>
							<td><input type="button" name="submit" value="Insert" onclick="request()" /></td>

						</tr>
					</table>
				</form>
				
			<div id="response">
			<!-- Null-->
			</div>
insert2.php is simply:

PHP Code:
echo $_POST['username']; 
Whenever I press Insert, it comes up with just "undefined" in the response div.

A live version is running here:
SUI Mock Up

Any help would be greatly appreciated :)
Gareth is offline  
Reply With Quote
Old 02-24-2008, 03:18 PM   #2 (permalink)
The Contributor
 
Join Date: Sep 2007
Posts: 89
Thanks: 1
Sam Granger is on a distinguished road
Default

Works in firefox :)
Sam Granger is offline  
Reply With Quote
Old 02-24-2008, 03:33 PM   #3 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 132
Thanks: 3
Gareth is on a distinguished road
Default

Yea; just fixed it :)

Thanks Sam.
Gareth is offline  
Reply With Quote
Reply



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

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:33 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0