jQuery - Resume form submit after ajax call

前端 未结 3 1612
萌比男神i
萌比男神i 2020-12-05 22:02

Is it possible to stop a form from submitting and then resubmitting the same form from within the success of an ajax call?

At the moment it gets to the success bit b

3条回答
  •  抹茶落季
    2020-12-05 22:52

    In one line you use $('form') to select the form to change its action, but then you use $(this) to try to select that same form. I would guess that this inside the callback function isn't what you expect it to be, and is something other than your form (possibly the window object).

    Just chain the calls:

    $('form').attr('action', 'http://example.com').unbind('submit').submit();
    

提交回复
热议问题