onclick for button not calling function

后端 未结 3 1503
失恋的感觉
失恋的感觉 2021-01-25 13:33

One of the problems I am experiencing at the moment is not being able to call a function in the onclick event of the submit button.

3条回答
  •  一个人的身影
    2021-01-25 14:17

    First, you should avoid inline handlers like that. Second, depending on the form submission process. You should have the button inside your

    tags. Then add .

    Otherwise, use jQuery and $.ajax() with a click event handler:

    $('#submit').on('click', () {
      $.ajax({check properties in jquery api docs}, (result) => { 
          // do something 
        }, 
        (e) => { 
          // do something on error 
      })
    })
    

提交回复
热议问题