html - Jquery lightbox form submitting -


i have form in user can enter fields , click button send submitted data php script adds data database.

the issue data isnt being sent.

the code:

$(document).on("click" ,".save_new_user",function() {     var form_data = {         "first_name"    : $(".first_name").val(),         "last_name"     : $(".last_name").val(),         "email"         : $(".email").val(),         "username"      : $(".username").val(),         "auth_level"    : $(".auth_level").find(":selected").text()     };      console.log(form_data);      var request = $.ajax({         method: "post",         url: "ajax/create_user.php",         data: form_data,     })     .done(function( data ) {         console.log(data);     }); }); 

the markup:

first name: <input type="text" name="first_name" class="first_name"> last name: <input type="text" name="last_name" class="last_name"> email address: <input type="text" name="email" class="email"> username: <input type="text" name="username" class="username"> auth level: <select class="auth_level"><option>admin</option><option>editor</option></select> <div class="save_new_user">add user</div> 

the console log of form_data returns following when form filled in: array ( [first_name] => [last_name] => [email] => [username] => [auth_level] => admin )

please help!

this works charm (i have replaced class id):

<head>   <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>       <script type="text/javascript">            $(document).on("click" ,".save_new_user",function() {                     var form_data = {                         "first_name"    : $("#first_name").val(),                         "last_name"     : $("#last_name").val(),                         "email"         : $("#email").val(),                         "username"      : $("#username").val(),                         "auth_level"    : $("#auth_level").find(":selected").text()                     };                      console.log(form_data);           }); /*             var request = $.ajax({                 method: "post",                 url: "ajax/create_user.php",                 data: form_data,             })             .done(function( data ) {                 console.log(data);             });*/     </script>     <title></title> </head> <body> first name: <input type="text" name="first_name" id="first_name"/> last name: <input type="text" name="last_name" id="last_name"/> email address: <input type="text" name="email" id="email"/> username: <input type="text" name="username" id="username"/> auth level: <select id="auth_level"><option>admin</option><option>editor</option></select> <input type="button" class="save_new_user" value="add user"></input>  </body> </html> 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -