Jump to content
php.lv forumi

ajax registacija problema


Lancom

Recommended Posts

vajag palidziba negrib izmest erroru kad visi lauki nau aizpilditi.. visu laiku rada Tu Esi vieksmigi regestrejies. kad visi lauki ir tuksi.

es ajax tiko macos bet man vajag palidziba. ar so scriptu.

<form action="" method="post" id="signup">
<input type="text" name="username" id="username" />
<input type="password" name="password" id="password" />
<input type="password" name="password_confirm" id="password_confirm" />
<input type="text" name="email" id="email" />
<button>Register</button> 
</form>

<div class="success" style="display: none;">Tu Esi vieksmigi regestrejies.</div>

 

common.js

$(document).ready(function() {
   $("form#signup").submit(function() {

       var username = $('#username').attr('value');
       var password = $('#password').attr('value');
       var password_confirm = $('#password_confirm').attr('value');
       var email = $('#email').attr('value');

       $.ajax({
           type: "POST",
           url: "complete_registraion.php",
           data: "username="+ username +"& password="+ password +"& password_confirm="+ password_confirm + "& email="+ email,
           success: function() {
               $('form#signup').hide(function(){$('div.success').fadeIn();})
           },
           error: function() {
               alert("Dati nau nosutiti aizpildiet visus laukus!");
           }
       });
   return false;
   });
});

Link to comment
Share on other sites

lasi dokumnetāciju par jquery ajax.

success() callback funkcija tiek izsaukta, nevis, kad ir veiksmīga reģistrācija, bet, kad ir veiksmīgs ajax pieprasījums. Un pie normālas tīkla un servera darbības, šim pieprasījumam vienmēr vajadzētu būt veiksmīgam.

Tev vajag uz pieprasījumu atbildēt ar kādiem datiem, kurus tu varētu klienta pusē ar js pārbaudīt un tad izlemt kā atbildēt - vai reģistrācija bija veiksmīga, vai nē.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...