how to configure PHP path

I’m learning Ajax form process. what’s my problem is When I submit a form it works and redirect to another page. on that page when I clicked back button from browser. I don’t redirect to previous page. if you give me an idea I can try . please help

 <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){

        }
    });
}

this how I process the form


Source: ajax

Leave a Reply