views:

142

answers:

1

Using jquery I'm trying to post textarea content back to a php backend. I can successfully alert out the textarea content, however when I use the $.post, firebug shows it as 'undefined'.

The post will successfully send the borrowing id. I have also tried giving the textarea a unique id but to no avail.

alert($('textarea').val());
    $.post("modules/readers/readers.php", 
             {   task: "return_reader", 
                 borrowing_id: $('#borrowing_id').val(), 
                 comment: $('textarea').val() },

             function(data){
            //etc
              }
    );
+1  A: 

I can't see anything wrong. What happens if you store the value beforehand, i.e:

    var s = $('textarea').val(); 
    $.post("modules/readers/readers.php",  
             {   task: "return_reader",  
                 borrowing_id: $('#borrowing_id').val(),  
                 comment: s }, 

             function(data){ 
            //etc 
              } 
    ); 
James Wiseman
For some reason this worked! I can't see any reason why it should though!??!
Paul