开发者

Jquery .post() method problem

开发者 https://www.devze.com 2023-02-10 02:05 出处:网络
I have the following Jquery function that should postmemberID as a variable.And I want to catch it in my add_comment.php file with$memberID = $_REQUEST[\'memberID\'] but it returns null.

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.

?

0

精彩评论

暂无评论...
验证码 换一张
取 消