I have a input field with id age. I am trying to pass this age and some other values from other input fields using ajax as follows-
var age = document.getElementById('age').value;
var wpm = document.getElementById('wpm').value;
var sex = document.getElementById('sex').value;
var queryString = "?age=" + age ;
queryString += "&wpm=" + wpm + "&sex=" + sex;
ajaxRequest.open("GET", "ajax-example.php" + queryString, true);
ajaxRequest.send(null);
ajaxRequest.open("GET", "ajax-example.php" + queryString, true);
so in my javascript part of my html document if i write
var age = document.getElementById('age').value;
the program executes perfectly.
But if i write this instead of the above statement -
var age =$('#age').val();
My age value is not passed
So my question is what is the differnece between the statements
var age = document.getElementById('age').value;
var age =$('#age').val();