Getting A Post ID VIA AJax

Discussion in 'Javascript' started by Spudster, Jul 16, 2014.

  1. Spudster


    Jul 16, 2014
    Likes Received:
    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, Jul 16, 2014
    1. Advertisements

  2. Spudster


    Jul 7, 2017
    Likes Received:
    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();

    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.
    osforum4, Jul 7, 2017
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.