Jquery .post() method problem
I have the following Jquery function that should post memberID as a variable.And I want to catch it in my add_comment.php file with $memberID = $_REQUEST['memberID']
but it returns null.
$('a.comment').die("click").live("click", function(e){
var getpID = $(this).parent().attr('id').replace('commentBox-','');
var comment_text = $("#commentMark-"+getpID).val();
if(comment_text != "Write a comment...")
开发者_运维知识库 {
$.post("lib/actions/add_comment.php?comment_text="
+comment_text+"&post_id="+getpID,{ memberID : 5
}, function(response){
$('#CommentPosted'+getpID).append($(response).fadeIn('slow'));
$("#commentMark-"+getpID).val("Write a comment...");
});
}
});
You need to URL-encode (with encodeURIComponent
) comment_text
, but why aren't you just sending that in the POST data?
Can't you do:
$.post("lib/actions/add_comment.php", {
comment_text: comment_text,
post_id: getpID,
memberID: 5
}, function (response) { //etc.
?
精彩评论