javascript - AJAX form data not sending from PHP included pages -


i building sign form, , want include div on main page. main page includes 'log in' form.

both forms included on page using php include commands in appropriate div i.e:

<?php include_once("login.php")?>     <?php include_once("signup.php")?> 

now when use ajax on second form i.e. signup.php form, sends information fields in first form. doesn't both email , password fields.

does know how can isolate information each form can send data each form separately? below relevant code forms , javascript.

here code first form(login.php):

  <form name="loginform" id="loginform" onsubmit="return false;">     <input style="margin-bottom:5px;" id="email" type="text" class="searchbox" onblur="checkusername()" maxlength="35" value="email">     <span id="emailstatus"></span>     <input id="password" class="searchbox" type="password" onfocus="emptyelement('status')"  maxlength="88" value="password">     <p><a href="#" id="loginbtn" onclick="login()">log in / <a href="#" onclick="forgotpass()">forgot password</a></p>     <span id="status"></span>   </form> 

and ajax it:

function login(){ //isolate variables form var p = _("password").value; var e = _("email").value; var status = _("status"); if(e != "email" && p != "password"){     _("loginbtn").style.display = "none";     status.innerhtml = 'please wait ...';  //start ajax request      var ajax = ajaxobj("post", "login.php");     ajax.onreadystatechange = function() {         if(ajaxreturn(ajax) == true) {             if(ajax.responsetext == "login_failed"){                 status.innerhtml = 'there problem. please check email , password , try again. ';                 _("loginbtn").style.display = "block";             }  else {                 window.location = "user.php?id="+ajax.responsetext;               }         }     }  //data being sent ajax call      ajax.send("e="+e+"&p="+p); } else {     status.innerhtml = "you're missing something.."; } }  function emptyelement(x){ //the _(x) function shortcut getelementbyid     _(x).innerhtml = ""; }  //this jquery used pre populate email , password fields "email" , "password" $('input .seachbox').each(function(){     $(this)     .data('default', $(this).val())     .focus(function(){         if ($(this).val() == $(this).data('default')||''){         $(this).val() = ''         }     })     .blur(function(){     var default_val = $(this).data('default');     if($(this).val() == ''){         $(this).val($(this).data('default'))     }     });  }); 

and second form(signup.php):

     <form name="signupform" id="signupform" onsubmit="return false;">       <div>email address:</div>     <input id="emails" type="text" class="searchbox" onfocus="emptyelement('status')" onkeyup="restrict('email')" maxlength="88">     <div>create password:</div>     <input id="pass1" type="password" class="searchbox" onfocus="emptyelement('status')" maxlength="16">     <div>confirm password:</div>     <input id="pass2" type="password" class="searchbox" onfocus="emptyelement('status')" maxlength="16">       </form>            <br> <a href="#" alt="signup" onclick="signup()">create account</a><p> <div class="statuserror"><span id="status" >this permanent error</span></div>     </div>       

and ajax it:

function signup(){ var e = _("email").value; var p1 = _("pass1").value; var p2 = _("pass2").value; var status = _("status"); if( e == "" || p1 == "" || p2 == ""){     status.innerhtml = "fill out of form data"; } else if(p1 != p2){     status.innerhtml = "your password fields not match"; } else {     status.innerhtml = 'please wait ...';     var ajax = ajaxobj("post", "signup.php");     ajax.onreadystatechange = function() {         if(ajaxreturn(ajax) == true) {             if(ajax.responsetext != "ok"){                 status.innerhtml = ajax.responsetext;                 _("signupbtn").style.display = "block";             } else {                 _("p1").innerhtml = "please 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("e="+e+"&p="+p1); } 

this screenshot firebug output - response post should appear red text on page.

edit - solution:- have - after 3 days found solution stupid had share it. changed id of status div "status" "status1" , found working fine now. think might because on login page have div named status browser unsure div put in , nothing. explains why signup.php page works when run alone in browser not when login.php included along in main page.

moral of story - make sure ids different!! help.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -