當(dāng)前位置:
首頁 >
JQeury form插件的ajaxForm方法和ajaxSubmit方法的区别
發(fā)布時(shí)間:2025/3/19
39
豆豆
生活随笔
收集整理的這篇文章主要介紹了
JQeury form插件的ajaxForm方法和ajaxSubmit方法的区别
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??
/***?ajaxForm()?provides?a?mechanism?for?fully?automating?form?submission.**?The?advantages?of?using?this?method?instead?of?ajaxSubmit()?are:**?1:?This?method?will?include?coordinates?for?<input?type="image"?/>?elements?(if?the?element*????is?used?to?submit?the?form).*?2.?This?method?will?include?the?submit?element's?name/value?data?(for?the?element?that?was*????used?to?submit?the?form).*?3.?This?method?binds?the?submit()?method?to?the?form?for?you.**?The?options?argument?for?ajaxForm?works?exactly?as?it?does?for?ajaxSubmit.??ajaxForm?merely*?passes?the?options?argument?along?after?properly?binding?events?for?submit?elements?and*?the?form?itself.*/ $.fn.ajaxForm?=?function(options)?{options?=?options?||?{};options.delegation?=?options.delegation?&&?$.isFunction($.fn.on);//?in?jQuery?1.3+?we?can?fix?mistakes?with?the?ready?stateif?(!options.delegation?&&?this.length?===?0)?{var?o?=?{?s:?this.selector,?c:?this.context?};if?(!$.isReady?&&?o.s)?{log('DOM?not?ready,?queuing?ajaxForm');$(function()?{$(o.s,o.c).ajaxForm(options);});return?this;}//?is?your?DOM?ready???http://docs.jquery.com/Tutorials:Introducing_$(document).ready()log('terminating;?zero?elements?found?by?selector'?+?($.isReady???''?:?'?(DOM?not?ready)'));return?this;}if?(?options.delegation?)?{$(document).off('submit.form-plugin',?this.selector,?doAjaxSubmit).off('click.form-plugin',?this.selector,?captureSubmittingElement).on('submit.form-plugin',?this.selector,?options,?doAjaxSubmit).on('click.form-plugin',?this.selector,?options,?captureSubmittingElement);return?this;}return?this.ajaxFormUnbind().bind('submit.form-plugin',?options,?doAjaxSubmit).bind('click.form-plugin',?options,?captureSubmittingElement); };??? 上面摘錄的代碼,是JQuery fom插件中ajaxFom這個(gè)方法的源代碼。
??? 下載地址為:http://plugins.jquery.com/form/
??? ajaxForm注釋的含義,大致強(qiáng)調(diào)這點(diǎn)意思:
??????? 用ajaxform,要么form表單中包含可以submit的元素,要么方法在注冊(cè)submit事件中調(diào)用。也就是說,用ajaxForm必須要有觸發(fā)submit的方法,否則無法提交form。
??? 相比而言,ajaxSubmit這個(gè)方法將直接觸發(fā)form的submit提交。
轉(zhuǎn)載于:https://my.oschina.net/dayu6/blog/280474
總結(jié)
以上是生活随笔為你收集整理的JQeury form插件的ajaxForm方法和ajaxSubmit方法的区别的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpringMVC 理论与实用技术(一)
- 下一篇: Resource 资源 ---Day09