Im trying to create a mail and password user to firebase, but im kepp getting this error:
Error: The browser redirected the page before the login request could complete. {code: "REQUEST_INTERRUPTED", stack: (...), message: "The browser redirected the page before the login request could complete."}
var ref = new Firebase("https://***.firebaseio.com");
$('.btn').click(function() {
var mail = $('#inputEmail3').val();
var pass = $('#inputPassword3').val();
ref.createUser({
email : mail,
password : pass
}, function(error) {
if (error === null) {
console.log("User created successfully");
} else {
console.log("Error creating user:", error);
}
});
});
$(document).ready();
If the element you are selecting with the
$('.btn')selector is a link the browser will navigate to the linked page before the asynchronousref.createUserfunction completes. To prevent this, add areturn falsestatement to the end of the click event handler. You can also add ane.preventDefault()statement at the top of the click handler which will ensure that the link navigation does not occur as shown below.