Javascript and AJAX, only works when using alert()

前端 未结 9 1171
借酒劲吻你
借酒劲吻你 2020-12-01 15:01

I am having trouble with my javascript. It seems to be acting oddly. This is what\'s going on. I have a form, after the user submits it, it calls a function(onsubmit event)

9条回答
  •  佛祖请我去吃肉
    2020-12-01 15:47

    I've had the same problem. Once I remove the alert("") it doesn't work. I figured it out and that's the deal.

    In HTML, when you use to place your button, the browser acts differently; when you click on it, after calling the event handler, it reloads the page and this is why you should place an alert("") just after your code to prevent the page from reloading.

    You can simply use instead of to prevent the browser from reloading the page.

提交回复
热议问题