How to call a PHP function from javascript?


Ajax is the easy and best solution for it. This is because of the ability to make calls to the server without reloading. You can pass parameters in the URL as well. Once the ajax get 200 response from server it will pass data to success function.

Source Code:

<script>
	$(document).ready(function (){
        $("button").click(function(){
            $.ajax({
                url: "url_goes_here",
                success: function(result) {
                    $("div").html(result);
                }
            });
        });
    });
</script>

Buy us coffee

Reviews and Comments