Reputation: 4187
There are 50 images on which you can Add / Delete comment , Which is a better way for implementation ?
1) Create an individual form for each image . Add the data to form and post it ? (50 forms would be created & 50 for deleting i think )
2) Use Jquery to select the text from the text box and ID and then post it using Ajax ?
I think the site
is using Approach 1 and
us using Approach 2 ? Which one is better ?
Upvotes: 0
Views: 1041
Reputation: 39
For method 2, something like this will work:
//LISTEN FOR YOUR SUBMIT COMMENT BUTTON TO FIRE
$("#commentButton").live('submit', function(e) {
//GET COMMENT
com = $("#commentField").text();
//POST COMMENT
$.post("commentsystem.php", { user: user, comment: com} );
});
Upvotes: 0
Reputation: 11020
I would use the second approach, it's more modern and you don't have to reload the page for an action.
But this is not a question with an definitive answer, because both ways will work fine.
Update: This is a tutorial for deleting a comment http://papermashup.com/jquery-ajax-delete/
With adding one it's basicially the same approach, but you send the referencing image id and the comment text.
Upvotes: 1