javascript - Send Form fields to jquery -


i'm trying pass form fields, ajax function insert user database.

but reason, alert (in js file) isn't showing anything.

any ideas i'm doing wrong?

my html:

        <form id="signupform">             <input id="signupformemail" type="text" name="email" placeholder=" e-mail"><br />             <input id="signupformpassword" type="text" name="password" placeholder=" password"><br />             <input id="signupformusername" type="text" name="username" placeholder=" user name"><br />             <input id="submitsignup" type="button" value="sign up" onclick="signup(this);">         </form> 

my javascript file:

function signup(elem) {    var postdata = $(this).serializearray();  //$('#myresults').html(postdata); alert($.param($(elem).serializearray()));  if($(elem).parent().children('#signupformemail').val() != ''){           // verifica se o email já existe     $.ajax(     {           url: "/newsletter/check-email/",           type: "post",           data: {type:'check',email:$(elem).parent().children('#signupformemail').val()}     }).done(function(response)     {            if(response == -1) {             $.ajax(             {               url: "/newsignup/registare/",               type: "post",               data: postdata             }).done(function(usercreated) {                 if(usercreated == 1) {                 alert('user created');                     /*                     $(elem).parent().children('#signupform').val('');                     $('#signupcompleted').show();                     */                 }                  else                 {                     /*$('#signuperror').show();*/                     alert('user not created');                 }             })              //testing             //$('#signupcompleted').show();         }         else //testing         {             $('.emailerror').show(); //testing         }      }     ); } } 

it looks serializing element itself. have serialize form, please check out.

function signup(elem)     {        var postdata = $('form').serialize();     //$('#myresults').html(postdata);     alert(postdata);      if($(elem).parent().children('#signupformemail').val() != ''){               // verifica se o email já existe         $.ajax(         {               url: "/newsletter/check-email/",               type: "post",               data: {type:'check',email:$(elem).parent().children('#signupformemail').val()}         }).done(function(response)         {                if(response == -1) {                 $.ajax(                 {                   url: "/newsignup/registare/",                   type: "post",                   data: postdata                 }).done(function(usercreated) {                     if(usercreated == 1) {                     alert('user created');                         /*                         $(elem).parent().children('#signupform').val('');                         $('#signupcompleted').show();                         */                     }                      else                     {                         /*$('#signuperror').show();*/                         alert('user not created');                     }                 })                  //testing                 //$('#signupcompleted').show();             }             else //testing             {                 $('.emailerror').show(); //testing             }          }         );     }     } 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -