Log in and stay on one page?

I am trying to make a smooth input function here =)

I want the "login experience" to be smooth and seamless, so I don’t want the user to "feel" as if he was "redirecting" and returning to the same page again.

So the process goes:

  • User X visits page A
  • X is not logged in
  • X clicks on Login btn (which lives in in the div along with the form)
  • Input fields and buttons disappear.
  • X logged in and remained on page A (without noticing a "redirect")

Thanks for all your answers!

+3
source share
3 answers

jQuery.load, ( ). .

:

function onSuccessfulLogin() {
   $("#content").load(window.location.href + " #content");
}

: , , , . , , , , , .

async. login, , script, , .

$("#loginform").bind("submit", function () {
    $.ajax({
       url: "login.php",
       method: "post",
       cache: false,
       dataType: "json", // for example
       data: $(this).serialize(),
       success: function (data) { // data is the JS object based on the JSON returned
          if (data.success) {
             $(this).fadeOut();
          } else {
             alert("bad login: "+data.error);
          }
       }
    });

    return false;
});
+1

, Ajax, . , JavaScript . ( , )

0

, , - AJAX , . , Dojo dijit.

0

Source: https://habr.com/ru/post/1764067/


All Articles