BikashKatwal
7 months ago
1766
4
Laravel

call controller method in javascript

Posted 7 months ago by BikashKatwal

method in controller

   public function update_invoice($id)
    {
        return 'success';
    }
    <div id="first-modal" class="reveal-modal" data-reveal>
                                        <h2>Confirmation</h2>
                                        <form>
                                            <button type="submit" class="next small-12 right">Confirm</button>
                                        </form>
                                        <a class="close-reveal-modal">&#215;</a>
                                    </div>
                                    <a class='open-first radius button>Paid</a>
    <script>
        $('a.open-first').on('click', function () {
            $('#first-modal').foundation('reveal', 'open');
        });
        $('a.close').on('click', function () {
            $('#first-modal').foundation('reveal', 'close', {

            });
        });
    </script>

I have to update it in the database, which I will write in the update_incoice function. but I want to call the controller's method in the javascript. How can I call the method?

or

Is there any way to route to the function when the button is clicked.

Please sign in or create an account to participate in this conversation.