0

I am trying to call a jquery function when clicking on a link, but it doesn't work, the function is not called at all...

Function:

<script>
    $(document).ready(function () {

        $('#notif').click(function () {
            var id = $(this).attr("data-id");
                        alert('test');
            $.ajax({
                type: "POST",
                url: "inc/showNotif.php",
                dataType: "html",
                data: {
                    id: id
                },
                success: function (result) {
                    $('.displayNotif').html(result);
                    console.log(result)
                }
            });

        });
    });
    </script>

Link:

<a href="#" id="notif" data-id="<?php echo $_SESSION['ID']; ?>" class="dropdown-toggle" data-toggle="dropdown">
                            <i class="icon-bell2"></i>
                            <span class="visible-xs-inline-block position-right">Activity</span>
                            <span class="status-mark border-orange-400"></span>
                        </a>

EDIT

I discovered that the code between tags doesn't execute at all, not even if I remove the onclick event.

EDIT 2

The issue is $(document).ready(function () the code works without it, but why?

SOLVED

Issue was some jquery errors preventing document.rady

0 Answers0