Sending and returning data with ajax - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajax

Description

Sending and returning data with ajax

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
 </head> //from  w  w  w  .j  a  v a2 s. c  om
 <body> 
  <form> 
   <input type="text" name="username" value="" class="authcheck"> 
  </form> 
  <script type="text/javascript">
    $(document).on('keyup', 'input', function(){
        var inputVal = $('input').val();
        $.post('auth.php', { 'username' : inputVal }, function(data){
            console.log(inputVal +' is '+ data);
        });
      });
    
      </script>  
 </body>
</html>

Related Tutorials