I am learning the Ajax process. My problem: when I submit the form, it works and redirects to another page. But when I click the back button, I am not redirected to the previous page. What am I doing wrong here?
<form id="form-admin-login"> <input name="username" type="text" placeholder="User name" class="input-field" required=""> <input name="password" type="password" placeholder="Password" class="input-field" required=""> </form> <button name="submit" onClick="submit_login()" class="btn btn-login">Login</button>
Ajax
function submit_login(){ $.ajax({ type: "POST", data: $("#form-admin-login").serialize(), url: "ajax/ajax-admin-login.php", dataType: "json", cache: false, beforeSend:function(){ }, success: function(data) { if(data['error']==0) { window.location.replace('dashboard.php'); } else if (data['error']==1) { $("#showError").removeClass("hide"); $("#error-message").html(data['message']); } }, error: function(jqXHR, textStatus, errorThrown){ } })
user2718590
source share