I modify a php comment system. I want add it after every article witch are query from database.

this is the php part

<?php
...
while($result = mysql_fetch_array($resultset))
{
$article_title = $result['article_title'];
...
?>
<form id="postform" class="postform">
<input type="hidden" name="title" id="title" value="<?=$article_title;?>" />
<input type="text" name="content" id="content" />
<input type="button" value="Submit" class="Submit" />
</form>
...
<?php
}
?>

this is the ajax part.

$.ajax({
type: "POST",
url: "ajax_post.php",
data: {title:$('#title').val(), 
    content:$('#content').val()
...

ajax_post.php

echo $title;
echo $content;

How to modify the ajax data part that each article's comment can send each data to the ajax_post.php? thanks a lot.

the whole js code

$(function($) {
$(document).ready(function(){
$(".Submit").click(function(){
var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var parent = $(this);
var anyBlank = 0;
if(anyBlank == "0")
{
var title    = $("#title").val();
var content   = $("#content").val();
$.ajax({
type: "POST",
url: "ajax_post.php",
data: {title:$('#title').val(), 
    content:$('#content').val()
},
success: function(date_added){
if(date_added != 0)
{
structure = '<div class="comment_date_added">'+date_added+'</div><div id="comment_text"><div id="comment_content">'+content+'</div>';				  	
$("#post_comment").prepend(structure);
}
});
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.