Wait script end before parsing HTML












1















My webpage is handling a user login in JavaScript. After the user login completed I have access to all user information.



I'm using Firebase Auth to log the user. I have a login page which works. In my main page, I have a script that check if the user is logged or not:



    firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
currentUser = user;

if (user != null) {
user.providerData.forEach(function (profile) {
console.log("Sign-in provider: " + profile.providerId);
console.log("--Provider-specific UID: " + profile.uid);
console.log("--Name: " + profile.displayName);
console.log("--Email: " + profile.email);
console.log("--Photo URL: " + profile.photoURL);
});
}
} else {
// No user is signed in.
console.log("No user is signed in.");
}
})


I want to display user's information on the page with html code. That means display his name, profile picture and other stuff like that.



The problem is that the html code is parsed before the data is fetched. So it displays nothing.



I don't know if it's the good way to this but I would like to know how to make the parsing of the html page wait for login completion.



Like I said I'm a beginner so I don't have enough knowledge to take the good decisions and find the best ways to do something. I'm sure there is another solution I don't know to bypass this situation.










share|improve this question

























  • Unfortunately, it's not really clear what you are trying to ask here.

    – Claies
    Nov 23 '18 at 3:24











  • Ok sorry trying to correct that.

    – Paul Bénéteau
    Nov 23 '18 at 3:26











  • Hope it's better now.

    – Paul Bénéteau
    Nov 23 '18 at 3:32













  • Hey Paul! From what I can see, are you using Ajax or a simple POST form with html? Also are you setting $_SESSION in php to track the logged in user?

    – GrandIQ
    Nov 23 '18 at 3:35











  • Actually PHP will not render HTML before the script end. Are you using AJAX?

    – Banujan Balendrakumar
    Nov 23 '18 at 3:36
















1















My webpage is handling a user login in JavaScript. After the user login completed I have access to all user information.



I'm using Firebase Auth to log the user. I have a login page which works. In my main page, I have a script that check if the user is logged or not:



    firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
currentUser = user;

if (user != null) {
user.providerData.forEach(function (profile) {
console.log("Sign-in provider: " + profile.providerId);
console.log("--Provider-specific UID: " + profile.uid);
console.log("--Name: " + profile.displayName);
console.log("--Email: " + profile.email);
console.log("--Photo URL: " + profile.photoURL);
});
}
} else {
// No user is signed in.
console.log("No user is signed in.");
}
})


I want to display user's information on the page with html code. That means display his name, profile picture and other stuff like that.



The problem is that the html code is parsed before the data is fetched. So it displays nothing.



I don't know if it's the good way to this but I would like to know how to make the parsing of the html page wait for login completion.



Like I said I'm a beginner so I don't have enough knowledge to take the good decisions and find the best ways to do something. I'm sure there is another solution I don't know to bypass this situation.










share|improve this question

























  • Unfortunately, it's not really clear what you are trying to ask here.

    – Claies
    Nov 23 '18 at 3:24











  • Ok sorry trying to correct that.

    – Paul Bénéteau
    Nov 23 '18 at 3:26











  • Hope it's better now.

    – Paul Bénéteau
    Nov 23 '18 at 3:32













  • Hey Paul! From what I can see, are you using Ajax or a simple POST form with html? Also are you setting $_SESSION in php to track the logged in user?

    – GrandIQ
    Nov 23 '18 at 3:35











  • Actually PHP will not render HTML before the script end. Are you using AJAX?

    – Banujan Balendrakumar
    Nov 23 '18 at 3:36














1












1








1








My webpage is handling a user login in JavaScript. After the user login completed I have access to all user information.



I'm using Firebase Auth to log the user. I have a login page which works. In my main page, I have a script that check if the user is logged or not:



    firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
currentUser = user;

if (user != null) {
user.providerData.forEach(function (profile) {
console.log("Sign-in provider: " + profile.providerId);
console.log("--Provider-specific UID: " + profile.uid);
console.log("--Name: " + profile.displayName);
console.log("--Email: " + profile.email);
console.log("--Photo URL: " + profile.photoURL);
});
}
} else {
// No user is signed in.
console.log("No user is signed in.");
}
})


I want to display user's information on the page with html code. That means display his name, profile picture and other stuff like that.



The problem is that the html code is parsed before the data is fetched. So it displays nothing.



I don't know if it's the good way to this but I would like to know how to make the parsing of the html page wait for login completion.



Like I said I'm a beginner so I don't have enough knowledge to take the good decisions and find the best ways to do something. I'm sure there is another solution I don't know to bypass this situation.










share|improve this question
















My webpage is handling a user login in JavaScript. After the user login completed I have access to all user information.



I'm using Firebase Auth to log the user. I have a login page which works. In my main page, I have a script that check if the user is logged or not:



    firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
currentUser = user;

if (user != null) {
user.providerData.forEach(function (profile) {
console.log("Sign-in provider: " + profile.providerId);
console.log("--Provider-specific UID: " + profile.uid);
console.log("--Name: " + profile.displayName);
console.log("--Email: " + profile.email);
console.log("--Photo URL: " + profile.photoURL);
});
}
} else {
// No user is signed in.
console.log("No user is signed in.");
}
})


I want to display user's information on the page with html code. That means display his name, profile picture and other stuff like that.



The problem is that the html code is parsed before the data is fetched. So it displays nothing.



I don't know if it's the good way to this but I would like to know how to make the parsing of the html page wait for login completion.



Like I said I'm a beginner so I don't have enough knowledge to take the good decisions and find the best ways to do something. I'm sure there is another solution I don't know to bypass this situation.







javascript html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 13:05









Billal Begueradj

5,858132641




5,858132641










asked Nov 23 '18 at 3:20









Paul BénéteauPaul Bénéteau

3231315




3231315













  • Unfortunately, it's not really clear what you are trying to ask here.

    – Claies
    Nov 23 '18 at 3:24











  • Ok sorry trying to correct that.

    – Paul Bénéteau
    Nov 23 '18 at 3:26











  • Hope it's better now.

    – Paul Bénéteau
    Nov 23 '18 at 3:32













  • Hey Paul! From what I can see, are you using Ajax or a simple POST form with html? Also are you setting $_SESSION in php to track the logged in user?

    – GrandIQ
    Nov 23 '18 at 3:35











  • Actually PHP will not render HTML before the script end. Are you using AJAX?

    – Banujan Balendrakumar
    Nov 23 '18 at 3:36



















  • Unfortunately, it's not really clear what you are trying to ask here.

    – Claies
    Nov 23 '18 at 3:24











  • Ok sorry trying to correct that.

    – Paul Bénéteau
    Nov 23 '18 at 3:26











  • Hope it's better now.

    – Paul Bénéteau
    Nov 23 '18 at 3:32













  • Hey Paul! From what I can see, are you using Ajax or a simple POST form with html? Also are you setting $_SESSION in php to track the logged in user?

    – GrandIQ
    Nov 23 '18 at 3:35











  • Actually PHP will not render HTML before the script end. Are you using AJAX?

    – Banujan Balendrakumar
    Nov 23 '18 at 3:36

















Unfortunately, it's not really clear what you are trying to ask here.

– Claies
Nov 23 '18 at 3:24





Unfortunately, it's not really clear what you are trying to ask here.

– Claies
Nov 23 '18 at 3:24













Ok sorry trying to correct that.

– Paul Bénéteau
Nov 23 '18 at 3:26





Ok sorry trying to correct that.

– Paul Bénéteau
Nov 23 '18 at 3:26













Hope it's better now.

– Paul Bénéteau
Nov 23 '18 at 3:32







Hope it's better now.

– Paul Bénéteau
Nov 23 '18 at 3:32















Hey Paul! From what I can see, are you using Ajax or a simple POST form with html? Also are you setting $_SESSION in php to track the logged in user?

– GrandIQ
Nov 23 '18 at 3:35





Hey Paul! From what I can see, are you using Ajax or a simple POST form with html? Also are you setting $_SESSION in php to track the logged in user?

– GrandIQ
Nov 23 '18 at 3:35













Actually PHP will not render HTML before the script end. Are you using AJAX?

– Banujan Balendrakumar
Nov 23 '18 at 3:36





Actually PHP will not render HTML before the script end. Are you using AJAX?

– Banujan Balendrakumar
Nov 23 '18 at 3:36












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440279%2fwait-script-end-before-parsing-html%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440279%2fwait-script-end-before-parsing-html%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen