Jquery Ajax selectors

Im trying to make something like this http://demos.99points.info/facebook_wallpost_system/ which is a comment system. I have the ajax code below except i don’t know how to uniqely select textareas. The challenge is that the number of posts is variable so all of the posts need to be uniquely identified so that when the data is put …

via HTML Language Development » Search Results » ajax:

Jquery Ajax selectors

Im trying to make something like this http://demos.99points.info/facebook_wallpost_system/ which is a comment system. I have the ajax code below except i don’t know how to uniqely select textareas. The challenge is that the number of posts is variable so all of the posts need to be uniquely identified so that when the data is put into the database i know which post it relates to.
JQUERY:
HTML/PHP

echo”

$post[$f]


“;
basically the HTML/PHP generates for each post on the page as to create a textarea and subimt button for each post. therefore the user can comment on each post.
……………………………………….

Using the markup in the link you provided, I would do something like:
var container = $(this).closest(‘.friends_area’);

var comment = $(container).find(‘.commentbox’).val();
var questionid = $(container).find(‘#hidden’).val();
var answerid = $(container).find(”).val();

A more correct solution would be something like:
HTML




JS
$(‘#posting’).on(‘submit’, ‘form’, function(e)

e.preventDefault();

var form = $(this).closest(‘form’);

$.post($(form).attr(‘action’), $(form).serialize(), function()
$(‘#commentContainer’).load(‘../writecomment.php’);
$(‘.commentBox’).val(”);
);
});

For more info: Jquery Ajax selectors

HTML Language Development » Search Results » ajax

Jquery Ajax selectors

Share this post:

Related Posts

Leave a Comment