我有处理表单提交事件的功能。
我想要在处理程序中做的是推迟默认行为,直到 Ajax 函数完成运行。
示例代码
$("#some_form").on("submit", function(event){
// Defer default event behavior
// Do some ajax function with a callback function to run
// after it is finished as an argument
ajaxFunction(function(){
// Do some stuff
// Let the default event behavior that was deferred to be run
});
});
有没有办法做到这一点?
编辑:
Ajax 代码只是一个示例。我可以这样做
$("#some_form").on("submit", function(event){
// Defer default event behavior
// Do some stuff
// Let the default event behavior that was deferred to be run
});