2011-02-09 3 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

ответ

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. 

?

Смежные вопросы