2011-02-09 83 views
0

我有以下Jquery函数应该将memberID作为变量。我想在我的add_comment.php文件中用$memberID = $_REQUEST['memberID']捕获它,但它返回null。Jquery .post()方法问题

$('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...");      
      }); 
     } 

    }); 
+0

你可以通过转义'comment_text'来尝试吗? – peakit 2011-02-09 18:54:13

回答

0

您需要URL-encode (with encodeURIComponent)comment_text,但你为什么不只是发送,在POST数据?

不能这样做:

$.post("lib/actions/add_comment.php", { 
    comment_text: comment_text, 
    post_id: getpID, 
    memberID: 5 
}, function (response) { //etc.