user1252280
user1252280

Reputation: 373

JQuery each loop concat this.text with string

I have a each loop that should send a private message:

[...].each(function () { $.get('board.php?func=list&id=' + (this.text) + '&send=Please read the board rules'); });

When I do 'alert(this.text);' within the each loop, everything works fine. But when I concatenate it with the string of the get Request, it doesn't work. Do I miss something?

Upvotes: 2

Views: 1579

Answers (1)

adeneo
adeneo

Reputation: 318182

Maybe writing it a little more verbose with $.ajax makes it clearer why you would you need to use $(this).text(), and not this.text

$(data from get request).find('#boardmembers')
                        .children('members')
                        .each(function() { 
                             $.ajax({
                                 type: 'GET',
                                 url : 'board.php',
                                 data: {
                                        func:'list',
                                        id  : $(this).text(),
                                        send: 'Please read the board rules'
                                 }
                             });
                        });

Upvotes: 2

Related Questions