陕西省建设八大员官方网站,做网站有哪些类型,免费网络验证,中铁建设工程项目公示网站这篇文章分享一下easyui常用的两种表单异步提交的方式。 目录
第一种#xff1a;利用ajax提交
$.post()
$.ajax()
第二种#xff1a;使用easyui提供的表单提交方式 首先#xff0c;准备一个简单的表单#xff0c;包含三个输入框#xff0c;在页面引入easyui的js文件。…这篇文章分享一下easyui常用的两种表单异步提交的方式。 目录
第一种利用ajax提交
$.post()
$.ajax()
第二种使用easyui提供的表单提交方式 首先准备一个简单的表单包含三个输入框在页面引入easyui的js文件。 第一种利用ajax提交
$.post()
!DOCTYPE html
htmlheadmeta charsetutf-8titleeasyui提交表单方式1/titlelink relstylesheet href../css/themes/icon.css /link relstylesheet href../css/themes/default/easyui.css /script src../js/jquery.min.js/scriptscript src../js/jquery.easyui.min.js/scriptscript src../js/easyui-lang-zh_CN.js/script/headbodyform idajax_form姓名input idname /年龄input idage /手机号input idphone /button typebutton idsubmit/button/formscript$(function($(#submit).click(function() {$.post(/xxx/save, {name: $(#name).val(),age: $(#age).val(),phone: $(#phone).val()}, function(resp) {// 处理响应的数据}, json);});));/script/body
/html $.ajax()
!DOCTYPE html
htmlheadmeta charsetutf-8titleeasyui提交表单方式1/titlelink relstylesheet href../css/themes/icon.css /link relstylesheet href../css/themes/default/easyui.css /script src../js/jquery.min.js/scriptscript src../js/jquery.easyui.min.js/scriptscript src../js/easyui-lang-zh_CN.js/script/headbodyform idajax_form姓名input idname /年龄input idage /手机号input idphone /button typebutton idsubmit/button/formscript$(function( $(#submit).on(click, function() {$.ajax({url: /xxx/save,type: post,data: {name: $(#name).val(),age: $(#age).val(),phone: $(#phone).val()},async: true,cache: false,dataType: json,processData: true,success: function(resp) {// 处理成功的响应},error: function(resp) {// 处理失败的响应}});});));/script/body
/html 第二种使用easyui提供的表单提交方式
easyui官网已经介绍了这种方式不过和上面的ajax提交不一样这种提交方式要给输入框设置name属性。 例如
!DOCTYPE html
htmlheadmeta charsetutf-8titleeasyui提交表单方式1/titlelink relstylesheet href../css/themes/icon.css /link relstylesheet href../css/themes/default/easyui.css /script src../js/jquery.min.js/scriptscript src../js/jquery.easyui.min.js/scriptscript src../js/easyui-lang-zh_CN.js/script/headbodyform idajax_form姓名input idname namename /年龄input idage nameage /手机号input idphone namephone /button typebutton idsubmit/button/formscript$(function($(#ajax_form).form(submit, {url: /xxx/save,success: function(resp) {// 处理成功的响应}});));/script/body
/html 好了文章就分享到这里了看完不要忘了点赞收藏哦~