How to echo the text inside the text box on button click? This is what I am trying to do:
<script type="text/javascript">
$(function() {  
    $('#button').click(function(){
        $.ajax({
            type: "POST",
            url: "index.php",
           data: {text:$('#name').val()}
        });
    });
});
</script>
<button id="button" type="button">submit</button>
<form method="post">
          <input type="text" id="name" name="name" size="31" placeholder="name ..." />
</form>
<?php echo $_POST['text']; ?>
 
     
     
    