randomly reloading the page after submit press with javascript
See original GitHub issueI’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:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
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
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”