Button doesn't work inside div, but works outside

Button doesn't work inside div, but works outside

Hi guys and thanks in advance for your help.

Hi guys and thanks in advance for your help.

I'm quite inexperienced with Ajax and I have been having a problem with something I have been trying to do. Its a basic notifications container using <div> and some other elements.

Problem is, I can't seem to get any buttons to work inside the div. My latest attempt is a 'Mark All Read' button at the bottom, using ajax, calling a php file (currently only has an echo for testing).

Any ideas on what i'm missing?

This is the button line, which sits inside another container for the notifications.

<div id="markallread" class="markAll">
    <input type="button" id="markallr" value="Mark All as Read" class="button">
</div>

And the ajax I have:

$(document).ready(function () {
    $("#markallr").click(function () {
        $.ajax({
            url : '../markread.php',
            type : 'POST',
            success : function () {  
                alert ("YES");
            },
            error : function () {
                alert ("NO");
            }
        });
    });
});

PHP file, like I have said is just an echo for testing.

<?php echo "Success"; ?>

Now, I can place the button at the top of the page, outside of the container, and it gives me the Alert 'Yes' but doesn't run the php file. Soon as I place it anywhere in the container, I lose all function.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

PHP Interview Questions with Solutions: Prepare for PHP Interview

Prepare for PHP Interviews. Set Variable With php.ini File. Logic & Output Behind PHP Code Segment. Class Concept, Error & Functions in PHP. Start PHP Now!

How to Include PHP in HTML

Welcome to this article on how to use PHP in HTML! Here, we try to get specific about exactly how PHP and HTML interact, at the level of a specific .php file. In other words, how do you actually include PHP in HTML, and what rules can and can’t you follow in weaving PHP and HTML together?

PHP Web Application Development Company

As a top **PHP Web Application Development Company in USA**[https://www.dataeximit.com/php-development-services/](https://www.dataeximit.com/php-development-services/ "https://www.dataeximit.com/php-development-services/"), we at Data EximIT have...