Ajax Using Jquery

Unknown | 11:44 AM
//------demo.php--------- 

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
function searchlist()
{
 var value=$('#search').val();
 $.ajax({
  type:'post',
  url:'action.php',
   data:'search='+value,
                beforeSend: function(){
      $("#result").html('<h1>Loading  ...</h1>'); 
  },
                success:function(value){
      $("#result").html(value);
  }
 });
}
</script> 

<input type="text" id="search" >
<input type="button" id="btn" onclick="seacrhlist()" value="GO">
<div id="result"></div> 

//---------action.php------------


<?php 
if(isset($_POST['search']))
{
  echo file_get_contents("http://google.com"); 
  echo "Hello Mr ".$_POST['search']." Welcome to Ajax Demo example <br />";
  echo "========================================================== <br />";
  echo "Author: Avinash Kumar Singh <br />"; 
} 
 
 ?>

No comments:

Post a Comment

Avinash Kumar Singh © 2013. All Rights Reserved | Powered by-Blogger