PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 13, 2022

[FIXED] How to display loading dialog until data is fetched in javascript

 July 13, 2022     async-await, javascript, web-deployment     No comments   

Issue

I want to display a loading dialog or screen until my data is completely fetched but don't know how to do it I saw some examples about async/await and promises but from there I am not getting any idea.so, please help me if someone knows how to do it.


Solution

You can use a flag variable to decide to show the dialog or not.

let flag = false # disable dialog in default

# bind the update function to some element
async update(){
  flag = true # enable dialog before api call
  const data = await fetchData() # fetch data
  flag = false # disable dialog after all data is fetched
}


Answered By - Zhu Lance
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing