我有一個表單和提交。如果有東西被填充,提交之前我想確保它的價值(用ajax),如果是,那麼我只能讓它繼續。所以,如何在AJAX事件結束之前暫停提交事件?
$('#contact').submit(function() {
// ajax
$.ajax({
type: 'POST',
url: $(this).attr('ajaxgetaccommodationsbyemail'),
success: function(answer) {
here a popup window opens, which waits until I press YES or NO
},
async: false
});
this is when return TRUE or FALSE
there should be something like
do while (popupWindowClosed)
so $.when is not an option
});
AJAX成功返回時設置全局變量。如果未設置全局變量,則取消'submit'事件。 – Blazemonger