jQuery Form Plugin: ajaxSubmit vs. ajaxForm Usage Guide
/* Usage Note: ----------- Do not use both ajaxSubmit and ajaxForm on the same form. These functions are mutually exclusive. Use ajaxSubmit if you want to bind your own submit handler to the form. For example,
$(document).ready(function() {
$('#myForm').on('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
Use ajaxForm when you want the plugin to manage all the event binding
for you. For example,
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
});
You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
form does not have to exist when you invoke ajaxForm:
$('#myForm').ajaxForm({
delegation: true,
target: '#output'
});
When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
/**
- Feature detection */
'每一行什么意思内容:这段代码是用于特性检测的。它会检测浏览器是否支持某些特性,以便在代码中针对不同的浏览器做出不同的处理。例如,这段代码可能会检测浏览器是否支持事件委托(delegation),以便在使用ajaxForm时做出不同的处理。'
原文地址: https://www.cveoy.top/t/topic/mFfz 著作权归作者所有。请勿转载和采集!