Javascript and AJAX, only works when using alert()

前端 未结 9 1156
借酒劲吻你
借酒劲吻你 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:45

    These guys are right but I would also be sure to return the bool from the validation method so the submission of the form is cancelled if the form is not valid.

    Something along the lines of:

    ...

    You could also always return false from validateRegForm and have the xmlhttp.onreadystatechange = function() submit the form if it is valid, or otherwise display your error message.

提交回复
热议问题