Click here to Skip to main content
15,564,470 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Need a simple *everything centered* html template Pin
Richard Deeming16-Nov-22 22:26
mveRichard Deeming16-Nov-22 22:26 
AnswerRe: Need a simple *everything centered* html template Pin
Jeremy Falcon15-Dec-22 14:00
professionalJeremy Falcon15-Dec-22 14:00 
QuestionFirefox won't let me change my privacy and security options. Pin
Member 1579676025-Oct-22 4:31
Member 1579676025-Oct-22 4:31 
QuestionFile upload not working, can't figure out why... Pin
DSB Audio (David Sweeney-Bear)22-Oct-22 13:34
DSB Audio (David Sweeney-Bear)22-Oct-22 13:34 
AnswerRe: File upload not working, can't figure out why... Pin
DSB Audio (David Sweeney-Bear)22-Oct-22 13:43
DSB Audio (David Sweeney-Bear)22-Oct-22 13:43 
GeneralRe: File upload not working, can't figure out why... Pin
Richard Deeming23-Oct-22 22:52
mveRichard Deeming23-Oct-22 22:52 
GeneralRe: File upload not working, can't figure out why... Pin
Jeremy Falcon15-Dec-22 14:05
professionalJeremy Falcon15-Dec-22 14:05 
QuestionIs it possible to store a value out of fetch API for use after page reload? Pin
DSB Audio (David Sweeney-Bear)4-Oct-22 10:23
DSB Audio (David Sweeney-Bear)4-Oct-22 10:23 
I'm trying to store a variable from data loaded through a fetch API, so that it's available for use outside the "promise" - i.e. so that I can generate a variable and them compare it on page reload. So far, I have something like this, but it doesn't work:
let extractedVal = await main(x);

let xml = "";
let apiUrl = "link/to/myfile.xml";

async function getXml() {
  let response = await fetch("link/to/myfile.xml");
  let text = await response.text();
  xml = new DOMParser().parseFromString(text, "text/xml");
  return xml;
}
async function main() {
  xml = await getXml(apiUrl)
  console.log(xml);
  var x = 1;
  return x;
}

i get the error at line 1:
Uncaught SyntaxError: await is only valid in async functions and the top level 
or:
x is not defined
if I don't use await

Surely, I'm not seeking to do the impossible here? All the methods I can find for "hoisting" a local variable into global scope seem to fail.

modified 4-Oct-22 19:44pm.

AnswerRe: Is it possible to store a value out of fetch API for use after page reload? Pin
Richard Deeming4-Oct-22 22:29
mveRichard Deeming4-Oct-22 22:29 
AnswerRe: Is it possible to store a value out of fetch API for use after page reload? Pin
jsc424-Oct-22 23:32
professionaljsc424-Oct-22 23:32 
QuestionXMLHttpRequest behaves differently on static HTML page to Wordpress site Pin
DSB Audio (David Sweeney-Bear)3-Oct-22 11:42
DSB Audio (David Sweeney-Bear)3-Oct-22 11:42 
SuggestionRe: XMLHttpRequest behaves differently on static HTML page to Wordpress site Pin
Richard Deeming3-Oct-22 22:40
mveRichard Deeming3-Oct-22 22:40 
GeneralRe: XMLHttpRequest behaves differently on static HTML page to Wordpress site Pin
DSB Audio (David Sweeney-Bear)4-Oct-22 4:00
DSB Audio (David Sweeney-Bear)4-Oct-22 4:00 
GeneralRe: XMLHttpRequest behaves differently on static HTML page to Wordpress site Pin
Richard Deeming4-Oct-22 4:25
mveRichard Deeming4-Oct-22 4:25 
QuestionHow to build course Content page in Html Css Pin
Member 1577435021-Sep-22 3:02
Member 1577435021-Sep-22 3:02 
QuestionCoworking Pin
Member 1576609713-Sep-22 4:21
Member 1576609713-Sep-22 4:21 
AnswerRe: Coworking Pin
rareprob solutions31-Oct-22 1:09
rareprob solutions31-Oct-22 1:09 
QuestionASP.NET Webform to go live Pin
Shao Voon Wong7-Sep-22 1:18
mvaShao Voon Wong7-Sep-22 1:18 
AnswerRe: ASP.NET Webform to go live Pin
Richard Deeming7-Sep-22 1:50
mveRichard Deeming7-Sep-22 1:50 
QuestionWeb Development Pin
William Worse3-Sep-22 2:52
William Worse3-Sep-22 2:52 
AnswerRe: Web Development Pin
Richard MacCutchan3-Sep-22 3:58
mveRichard MacCutchan3-Sep-22 3:58 
AnswerRe: Web Development Pin
rareprob solutions18-Oct-22 2:33
rareprob solutions18-Oct-22 2:33 
QuestionHTML6 as a "living document" will that work? Pin
Member 150787168-Aug-22 15:35
Member 150787168-Aug-22 15:35 
QuestionFullscreen scrolling image and adding more images Pin
Member 157264913-Aug-22 7:33
Member 157264913-Aug-22 7:33 
QuestionHow to get saved data from option select in PHP? Pin
imbruceter1-Aug-22 1:36
imbruceter1-Aug-22 1:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.