Having Trouble With JQuery and Ajax
Hi,
I have been writing a simple test program to test out the functionality of AJAX. It is a simple application where you type in your name into a text field and hit submit and the <div> below it should say "Hello, [Person's Name]. When I fill out the text field and click the button I get absolutely nothing. I open FireBug and I can see that a request was made apparently it never hit the PHP.
I am programming through eclipse php on Ubuntu 10.04 and here is my code for the main file, Main.php:
- <html>
<head>
<script type="text/javascript" src = "jquery.js"></script>
<script type="text/javascript">
$.ajaxSetup ({
cache: false
});
$(document).ready(function(){
$("#driver").click(function(event){
var name = $("#name").val();
$("#stage").load('result.php', {"name":name} );
$("#stage").ajaxError(function(event, request, settings ){
$(this).html("<h1>Error in loading page.</h1>");
});
});
</script>
</head>
<body>
<p>Enter Your Name and Click the Button Below</p>
<input type="text" id="name"/><br />
<div id="stage">
Stage
</div>
<input type="button" id="driver" value="Show Result"/>
</body>
</html>
And here is the requested php file, request.php:
- <?php
if($_REQUEST['name'])
{
$name = $_REQUEST['name'];
echo "Welcome".$name;
}
?>
Thank you...