I am creating a login form dynamically, using jQuery and AJAX response. Form is created and displaying properly. But, I'm not able to read the form data.
This is my code:
$(document).ready(function(){
$('#proper-form').on( 'click', '#submit-button', function() { // loginForm is submitted
alert ("here");
var username = $('#email').attr('value'); // get username
var password = $('#password').attr('value'); // get password
alert (password);
alert (username);
// code for form submit using ajax
});
});
It's alerting undefined undefined
for both username and password.
Can anyone help me in figuring out what's wrong here?