-1

enter image description here

I would like to get the var username, and use it in:

enter image description here

I just need to find a way to append the var username from thee function loginMe(), to user_url, so that I can retrieve data from mysql.

Vicks
  • 9
  • 1
  • Does this answer your question? [What is the scope of variables in JavaScript?](https://stackoverflow.com/questions/500431/what-is-the-scope-of-variables-in-javascript) – Krzysztof Krzeszewski Feb 04 '22 at 14:49
  • https://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file – TrystanHumann Feb 04 '22 at 14:49

1 Answers1

0

There are no way to get variable value from one function to another unless you pass it by parameter or set it as global variable.

When executing loginMe(). You can pass value by calling getUserInfo( username ). Or when you are executing loginMe() you can set username in localStorage and get it in getUserInfo() function from localStorage. Or You can set the value as global variable by window.username then you will be able to access it.

F.Abdullah
  • 31
  • 5