0

hi All
i have taken from internet script that post data with the help of AJAX and PHP
below is script

<html>
	<head>		
		<script type="text/javascript" src="prototype.js"></script>
		<script>

			function sendRequest() {
				new Ajax.Request("test.php", 
					{ 
					method: 'post', 
					postBody: 'name='+ $F('name'),
					onComplete: showResponse 
					});
				}

			function showResponse(req){
				$('show').innerHTML= req.responseText;
			}
		</script>
	</head>

	<body>
		<form id="test" onsubmit="return false;">
			<input type="text" name="name" id="name" >
			<input type="submit" value="submit" onClick="sendRequest()">
		</form>
		
		<div id="show"></div>
	</body>

</html>

what does here

'name='+ $F('name'),

mean
i espesially confused with

$F('name')

Thanks in advance for attention

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by scrappedcola
0

From the site the code looks like it's from: "Making AJAX Request
The function below sends the request out to our text.php script using the method post with the value filled in the input text box 'name' using $F(‘name') which retrieves the values we put in the text box. The onComplete: showResponse returns the repose from test.php".
The site isn't using straight up javascript but a library that wraps up some of the commonly used functionality into specific calls. According to the site you need to check out the library prototype. Specifically the $F{'name'} is the equivalent of :

document.getElementById("name").value;

Edited by scrappedcola: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.