Very important role is contributed by ajax of javascript programming language in development of website and web applications.

Ajax with PHP Language


<!-- HTML code for input (value of which would be used in ajax file), button (which would be used for action of ajax) and div (where the result form ajax file would be pasted). -->
<input class="input_class" type="text" />
<button class="button_class">Click</button>

<div id="div_target" >This is the div where the results from the file (to be interacted by ajax) would be pasted here while replacing the text already herein.</div>

<!-- JavaScript Code -->
<script>
$('.button_class').click(function(){
                var any_var = $('.input_class').val();
                 if(any_var != '' )
                {
                    $.ajax({
                        url:"file_source.php",
                        method:"POST",
                        data:{any_var:any_var},
                        success:function(data)
                        {
                           $("#div_target").value("");
                        }
                    });
                }
                else
                {
                    alert("Put Some Text");
                }
            });
});

</script>