check the ajax response you get the http code must be 302. which is a redirect. you need to check the http code and redirect yourself using js.
Ajax call is not working in my code, find the below code.
<!DOCTYPE html> <html lang="en"> <header> <meta name="_token" content="{!! csrf_token() !!}"/> </header> <body> <div class="secure">Secure Login form11</div> <form action="login" method="POST" id="myform"> <div class="control-group"> <div class="controls"> <input type="text" name="email" id="" class="form-control span6" placeholder="Email">
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="password" class="form-control span6" name="password" placeholder="Please Enter your Password">
</div>
</div>
<button type="button" class="send-btn" name="login">login</button>
</form> </body> <script type="text/javascript" src="assets/js/jquery.min.js"></script> <script type="text/javascript" src="assets/js/jquery.ui.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup({ headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') } }); $('.send-btn').click(function(){ $.ajax({ url: 'login', type: "post", data: {'email':$('input[name=email]').val(), '_token': $('input[name=_token]').val()}, success: function(data){ alert(data); } }); }); }); </script> </html>Throwing: jquery.min.js:6 POST http://localhost/mylaravel/public/login 500 (Internal Server Error)
Ajax call is not working in my code, find the below code.
<!DOCTYPE html> <html lang="en"> <header> <meta name="_token" content="{!! csrf_token() !!}"/> </header> <body> <div class="secure">Secure Login form11</div> <form action="login" method="POST" id="myform"> <div class="control-group"> <div class="controls"> <input type="text" name="email" id="" class="form-control span6" placeholder="Email">
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="password" class="form-control span6" name="password" placeholder="Please Enter your Password">
</div>
</div>
<button type="button" class="send-btn" name="login">login</button>
</form> </body> <script type="text/javascript" src="assets/js/jquery.min.js"></script> <script type="text/javascript" src="assets/js/jquery.ui.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup({ headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') } }); $('.send-btn').click(function(){ $.ajax({ url: 'login', type: "post", data: {'email':$('input[name=email]').val(), '_token': $('input[name=_token]').val()}, success: function(data){ alert(data); } }); }); }); </script> </html>Throwing: jquery.min.js:6 POST http://localhost/mylaravel/public/login 500 (Internal Server Error)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community