Answers for "woo axios"

0

woo axios

<script>
        // Here I define a path to 'myActions.php' file
        const myActionsUrl = '<?php echo get_template_directory_uri() ?>'+'/myActions.php'

        var params = new URLSearchParams();
        params.append('action', 'my_own_function');
        params.append('price', '199');

        async function runPHP(){
            axios.post(myActionsUrl, params)
            .then(function (response) {
                console.log(response)
            })
            .catch(function (error) {
                console.log(error);
            });
        }
    </script>

    <button onclick="runPHP()">Run myActions!</button>
Posted by: Guest on September-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language