showing results for - "woo axios"
Noam
18 May 2019
1    <script>
2        // Here I define a path to 'myActions.php' file
3        const myActionsUrl = '<?php echo get_template_directory_uri() ?>'+'/myActions.php'
4
5        var params = new URLSearchParams();
6        params.append('action', 'my_own_function');
7        params.append('price', '199');
8
9        async function runPHP(){
10            axios.post(myActionsUrl, params)
11            .then(function (response) {
12                console.log(response)
13            })
14            .catch(function (error) {
15                console.log(error);
16            });
17        }
18    </script>
19
20    <button onclick="runPHP()">Run myActions!</button>
21
similar questions
queries leading to this page
woo axios