I have the following form which works fine without the ajax
echo "
<form action='upload_Comment.php?post_id=$post_id' method='post' id='comments'>
<textarea class='form-control' name='comment' rows='1'></textarea>
<input type='submit' name='post_comment'>
</form>
    ";
But I need to use ajax to prevent the page from reloading when the form is submitted.
$(document).ready(function(){
  $('#comments').on('submit', function(e) {
    e.preventDefault();
    $.ajax({
      url: "upload_comment.php?post_id= + post_id ",
      type: "POST",
      data: new FormData(this),
      dataType : 'json',
      contentType: false,
      processData: false,
      success : function(data){                   
                              console.log(data);
                      },
                      error: function(){alert('Error!')}
    })
  });
});
I need a way to pass $post_id parameter value every time I submit the new post and that post_id is unique for each post. How can I pass that post_id parameter in ajax form url?
 
     
     
     
     
    