0

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.

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by cj333
0

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);
}
});
});
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.