Skip to content
Recommend our themes and earn 30% of our share of every sale you bring. Free to join.Earn by recommending our themes Become an affiliate

How to call a PHP function from javascript?

Updated 02 Jul 2018
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>

More code answers

Comments

Log in to leave a comment.