AJAX not Working with php as supposed

You can try to use .one()

From documentation:

The .one() method is identical to .on(), except that the handler is unbound after its first invocation.