jQuery callback function not working
When I type something in the text box, nothing happens.
This is my HTML file:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>POST/GET Data (HTTP Request)</title>
<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>
</head>
<body>
<input type="text" id="name" />
<div id="name_feedback"></div>
<script type="text/javascript" src="js/functions.js"></script>
</body>
</html>
This is the jQuery:
$('#name').keyup(function() {
var name = $('#name').val();
$.post('php/process_name.php', { name: name }, function(data) {
$('#name_feedback').html(data);
});
});
This is PHP:
<?php
if(isset($_POST['name'])) {
$name = $_POST['name'];
echo strrev($name);
}
?>
I want to echo out the reverse string as the user types something.
No comments:
Post a Comment