jquery ajax error -
i wrote login form on submit user supposed logged in, not working. please let me know error is, form
<form id ="loginform_" action=""> <a href=""id="slidedownclose">x</a> <h2> login form</h2> username:<input type="text" id="uname" name="user_name" /><br/><br/> password:<input type="password" id="password" name="password" /><br/><br/> <input type ="submit" id ="log" class="logclass" value="log in"/><br/><br/> <a id ="lost_password" href ="/frontend_dev.php/forgotpassword">forgot password </a> </form>
this jquery code
$(document).ready(function() { $("#loginform_").validate({ rules: { user_name: "required", password: "required" } }); $(".logclass").click(function() { var data =$("#loginform_").serialize(); $.ajax({ type: "post", url: "/frontend_dev.php/login/new", data: data, success: function(){ alert('success'); window.location.replace("/frontend_dev.php/user"); }, error: function(){ alert(data); } }); }); });
well 1 of problems button of type submit , not telling prevent default behavior.
$(".logclass").click(function(e) { // code e.preventdefault(); }
next it's better use following call click.
$('#log').click(function(e){ }
it's better access id class. option change button like.
<input type='button' id='log' class='logclass' value='log in'/>
that should started in better direction.
Comments
Post a Comment