2

I have a while loop in php that fetches assoc result of a query and then displays them in a class with an id of the user who made that post, im trying to send the id of the class to php as am i sending the num variable however i seem to be getting an undefined index error when trying to send it.

This is what i have so far -

(".eventer button[name=lol]").click(function() {
    console.log('clicked');
    var ida = this.id;
    thisBtn = $(this);
    parent = $(this).parent();
    num = parent.data('num');
    id = parent.data('id');
    if (typeof num != 'number') {
        num = 0;
        $(this).attr('disabled', true);
        $.post('javas.php?ida= ' + ida, {
            num: (num + 1),
            id: id
        }, function(data) {
            console.log('Ajax success');
            parent.next('.status').html(data);
            thisBtn.attr('disabled', false); // reset  });
            console.log('Ajax success');
            parent.data('num', ++num);
            parent.next('.status').html(data);
            thisBtn.attr('disabled', false); // reset 
        });
    });

console.log('-- end');

Any help is appreciated thanks.

1 Answer 1

1

Should you be using:

.attr('id');

instead of:

.data('id');
Sign up to request clarification or add additional context in comments.

2 Comments

i dont think thats the problem
Can you show us the html, the only issue I can see in the js is the data('id') ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.