0

I have this code here and I'm trying to read the ids of all the elements of the selected class, but the result is always undefined. Any suggestions?

$(".notification_new").click(() => {
    let id = $(this).attr('id');
    alert(id);
    $.post("/update.php", {
        reqType: "changeNotificationStatus",
        notifId: id,
        dataType: "json"
        }, response => {
            alert(response);
        )
    })
});
consolenine
  • 159
  • 1
  • 11
  • Specifically which "result" is `undefined`? Can you also include the HTML and make this a runnable [mcve] which demonstrates the problem? – David Nov 03 '22 at 15:05
  • 2
    Extremely related: https://stackoverflow.com/questions/34361379/are-arrow-functions-and-functions-equivalent-interchangeable. _"Arrow functions don't have their own this or arguments binding."_ So change `click(() => {` to `function() {` – j08691 Nov 03 '22 at 15:06

0 Answers0