How to avoid automatic page reload after XMLHttpRequest call?

前端 未结 2 1348
迷失自我
迷失自我 2021-01-12 20:33

I know this is a bit paradoxal because XMLHttpRequest shouldn\'t be reloading the page, and it\'s the whole point of it.

Tried in Chrome latest version, Safari on iO

相关标签:
2条回答
  • 2021-01-12 21:03

    Use event.preventDefault() when observing button click in your form.

    0 讨论(0)
  • 2021-01-12 21:13

    Any chance you're triggering this by submitting a form? If you don't return false in the onsubmit handler, the form will still be submitted.

    0 讨论(0)
提交回复
热议问题