How to write data option in jQuery.ajax() function when it include in a mysql_query?

Posted by cj333 on Stack Overflow See other posts from Stack Overflow or by cj333
Published on 2011-01-28T23:22:46Z Indexed on 2011/01/28 23:25 UTC
Read the original article Hit count: 131

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about jquery-ajax