Getting A Post ID VIA AJax

Joined
Jul 16, 2014
Messages
1
Reaction score
0
Hello.
I apologize that I cannot provide the source since I'm on my tab right now but I try to explain as clear as possible, What I am trying to archive is get an id of a post in the database so say when a user comments then hits enter that will then get the post ID From the groups_posts table to insert the id in the groups_comments table since each comments needs the id of the post it is assigned to, I cannot seem to archive this as Ajax JQUERY won't get the id of the post where as pure php worked fine :/

The question is when making a group feature like FB what's the best way to get an id of the post that the user has commented on so the comment knows what post to display under. While using JQUERY


Hoe this makes sense.

Spudster
 
Joined
Jul 7, 2017
Messages
4
Reaction score
0
You can try AJAX once.
You need to call PHP file with ajax request so it will insert data without reloading your page.

var values = $(this).serialize();

$.ajax({
url: "your.php",
type: "post",
data: values , //pass id
success: function (response) {
// you will get a response from your PHP page (what you echo or print)

},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});

If you can provide snippets of source code then I can help liitle bit more.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top