php - jQuery callback function not working -
when type in text box, nothing happens.
this 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 jquery:
$(document).ready(function(){ $('#name').keyup(function() { var name = $('#name').val(); $.post('php/process_name.php', { "name": name }, function(data) { $('#name_feedback').html(data); }); }); });
this php:
<?php if(isset($_post['name'])) { $name = $_post['name']; echo strrev($name); } ?>
i want echo out reverse string user types something.
you can @ browser itself(without php) jquery.
$(function(){ $('#name').keyup(function() { var name = $('#name').val(); $('#name_feedback').html(name.split("").reverse().join("")); }); });
Comments
Post a Comment