question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

randomly reloading the page after submit press with javascript

See original GitHub issue

I’m submitting a…

[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->
[ ] Feature request
[ ] Documentation issue or request
[ ] Other: <!-- Please describe: -->

Current behavior

i have a project that takes asynchronous data from json server(locally for testing) and then i post them to the main page. What i noticed is that after i was pressing the submit button (without a form) it randomly reloaded the page while i got a console message “Navigated to http://127.0.0.1:5500/microposts/” where microposts are a test project for an async await http request. I was searching for a bug in my code but when i opened the Apache server i have installed it run as it was supposed to. after the submit button the page was reloading. I traied the prevent default and everything else i found on the internet, but when i switched to the preinstalled apache server on my laptop it worked fine. i hope i get some instructions on how to fix this. Thank you in advance!

Expected behavior

Environment

Browser:

- [x] Chrome (desktop) version latest
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:

- Live Server:  latest <!-- Check which version is installed --> 
- Platform: Mac ans Windows <!-- Mac, Linux, Windows -->
- Visual Studio Code: <!-- `code --version` -->

Others

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
ritwickdeycommented, Jun 10, 2018

Live Server will reload the if any changes made in the directory. (CREATE/EDIT/DELETE of any file in the workspace).

The change event is made by chokidar (npm library)

@iRuisu

1reaction
jturnercodecommented, Jul 13, 2021

Old post but thought id share my case and solution, as I recently went through same problem. As ritwickdey mentions live server refreshes if it notices any change to files in directory In my case, i was sending post request to local sqlite db in same directory. Live server would refresh page after the db updated To prevent this add filetype or file to be ignored in settings.json Go to vscode settings --> type ‘liveserver ignore files’ -->click ‘edit in settings.json’ and add the file extensions that may be causing issue In my case i added “**/*.db”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop form refreshing page on submit - javascript - Stack Overflow
One great way to prevent reloading the page when submitting using a form is by adding return false with your onsubmit attribute.
Read more >
Fix "Aw, Snap!" page crashes and other page loading errors
Usually, you can reload the page to fix the error. Tap More More and then Reload Reload . If that didn't work... Step...
Read more >
What went wrong? Troubleshooting JavaScript - MDN Web Docs
Save your page and refresh, and you should see the error has gone. Now if you try to enter a guess and press...
Read more >
Meta refresh - Wikipedia
It is also possible to instruct the browser to fetch a different URL when the page is refreshed, by including the alternative URL...
Read more >
Refresh a Web Page in JavaScript - STechies
This method reloads the page from directly the browser's cache by default. If the forceGet property is set to true, the web page...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found