javascript - ( Signup Form ) Ajax seems to not be working, only showing up my echo, not my message to look in your email -
first click on button, tells in terms, do. officially makes account. although, once click on button should've redirected message header. instead shows echo, doesn't direct message. stays is, , says signup_success.
my ajax seems fine.
function ajaxobj( meth, url ) { var x = new xmlhttprequest(); x.open( meth, url, true ); x.setrequestheader("content-type", "application/x-www-form-urlencoded"); return x; } function ajaxreturn(x){ if(x.readystate == 4 && x.status == 200){ return true; } } not sure if code, or ajax thats wrong.
function restrict(elem){ var tf = _(elem); var rx = new regexp; if(elem == "email"){ rx = /[' "]/gi; } else if(elem == "username"){ rx = /[^a-z0-9]/gi; } tf.value = tf.value.replace(rx, ""); } function emptyelement(x){ _(x).innerhtml = ""; } function checkusername(){ var u = _("username").value; if(u != ""){ _("unamestatus").innerhtml = 'checking ...'; var ajax = ajaxobj("post", "signup.php"); ajax.onreadystatechange = function() { if(ajaxreturn(ajax) == true) { _("unamestatus").innerhtml = ajax.responsetext; } } ajax.send("usernamecheck="+u); } } function signup(){ var u = _("username").value; var e = _("email").value; var p1 = _("pass1").value; var p2 = _("pass2").value; var c = _("country").value; var g = _("gender").value; var status = _("status"); if(u == "" || e == "" || p1 == "" || p2 == "" || c == "" || g == ""){ status.innerhtml = "fill out of form data"; } else if(p1 != p2){ status.innerhtml = "your password fields not match"; } else if( _("terms").style.display == "none"){ status.innerhtml = "please view terms of use"; } else { _("signupbtn").style.display = "none"; status.innerhtml = 'please wait ...'; var ajax = ajaxobj("post", "signup.php"); ajax.onreadystatechange = function() { if(ajaxreturn(ajax) == true) { if(ajax.responsetext.indexof("signup_success")){ status.innerhtml = ajax.responsetext; _("signupbtn").style.display = "block"; } else { window.scrollto(0,0); _("signupform").innerhtml = "ok "+u+", check email inbox , junk mail box @ <u>"+e+"</u> in moment complete sign process activating account. not able on site until activate account."; } } } ajax.send("u="+u+"&e="+e+"&p="+p1+"&c="+c+"&g="+g); } } function openterms(){ _("terms").style.display = "block"; emptyelement("status"); } /* function addevents(){ _("elemid").addeventlistener("click", func, false); } window.onload = addevents; */ i've been working on while now, going smooth, bamb button didn't work. fixed it, , won't direct message.
Comments
Post a Comment