I am trying to extract the value from a textarea using jquery, but my debugger keeps saying that my variable questVal is undefined. Any ideas? Here’s the code:
approveThis:function(event) {
var thisId = parseInt(event.target.id.replace('app', ''));
var questId = thisId;
var questSelect = '#questID' + questId;
var questVal = $(questSelect).val();
$.ajax({
url:"includes/php/whatifApprove.php",
data:{ approving:true, idNum:thisId, questionName:questVal },
type:"POST",
cache:false,
success: function(data){
console.log(questVal);
$('#testMessages').html(data);
}
});
return false;
You really haven’t provided enough info, but in general that means when you do
$(questSelect).val();it is returning undefined. You are not selecting what you think you are selecting.
I would put a debugger at the first line in the
approveThisfunction, and step thru line by line, making sure everything is what you expect it to be.