Ajax Submit

ajax提交form

余生颓废 提交于 2021-01-09 10:45:18
function ajaxAddForm() { var options = { url: "${path}/upload/uploadFile?path=app/banners", type: "POST", dataType: "json", contentType: "application/json;charset=UTF-8", success: function(data) { if(data.result) { $("#showImg").attr("src", '${fna:getProperties("img.show.url.app.banners")}/' + data.name); $("input[name='image']").val(data.name); } else { $.messager.alert('错误', '图片上传失败!', 'error'); } } }; $("#fid").ajaxSubmit(options); } 来源: oschina 链接: https://my.oschina.net/u/3795961/blog/1833924

jQuery中FormData的使用

旧巷老猫 提交于 2021-01-03 11:42:42
web中数据提交事件是常常发生的,但是大多数情况下我们不希望使用html中的form表单提交,因为form表单提交会中断当前浏览器的操作并且会调到另一个地址(即使这个地址是当前页面),并且会重复加载一些html浪费带宽,我们希望达到一个无刷新的、异步的提交效果来给用户更好的体验,这时候就要使用ajax,ajax可以不依赖表单自行发起一次http请求并且取回服务器响应的数据,这就是ajax的简便之处。我们这里使用JQuery中封装好的ajax函数,更加简便。下面列举几个使用ajax异步提交数据的方法。 一:jquery.js中的$.ajax方法 此方法依赖jquery.js插件,有很多版本,可以自己下载。 我们需要在此$.ajax方法中指定一些参数,比如请求地址、请求类型、所需要传输的数据、请求成功后需要执行的操作,这里简略说一下。 $.ajax({ url: " 你的url地址 " , type: ' post ' , data:{key: ' value ' }, success:function(){ alert( ' 成功 ' ); } }) 这是$.ajax方法的简单用法。其中参数data是你要传输的数据,这里的data支持Json对象和字符串。data数据如果是一个form表单里面的,自己写一个json很慢,可以使用jquery里面的serizlize()方法

迅睿CMS 登录/注册功能在其他页面调用

余生长醉 提交于 2020-08-09 21:11:27
使用环境:在首页或其他页面进行注册或登录功能 一、登录功能 <form class="content" id="loginform" method="post" novalidate="novalidate"> {dr_form_hidden()} <div class="form-group"> <div class="input-icon"> <i class="fa fa-user"></i> <input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="账号/邮箱/手机" name="data[username]"> </div> </div> <div class="form-group"> <div class="input-icon"> <i class="fa fa-lock"></i> <input class="form-control placeholder-no-fix" type="password" autocomplete="off" placeholder="登录密码" name="data[password]"> </div> </div> {if $ci->member_cache['login']['code']} <div

jQuery Ajax文件上传

拥有回忆 提交于 2019-12-22 19:39:27
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我可以使用以下jQuery代码使用ajax请求的POST方法执行文件上传吗? $.ajax({ type: "POST", timeout: 50000, url: url, data: dataString, success: function (data) { alert('success'); return false; } }); 如果有可能,我是否需要填写 data 部分? 这是正确的方法吗? 我只将文件发布到服务器端。 我一直在搜索,但是我发现是一个插件,而在我的计划中我不想使用它。 至少目前是这样。 #1楼 通过ajax上传文件不再需要iframe。 我最近自己做了。 查看以下页面: 在AJAX和jQuery中使用HTML5文件上传 http://dev.w3.org/2006/webapi/FileAPI/#FileReader-interface 更新了答案并进行了清理。 使用getSize函数检查大小或使用getType函数检查类型。 添加了progressbar html和css代码。 var Upload = function (file) { this.file = file; }; Upload.prototype.getType = function() { return this

jQuery AJAX提交表单

心不动则不痛 提交于 2019-12-16 16:07:27
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我有一个名称为 orderproductForm 的表单,输入的数量不确定。 我想做某种jQuery.get或ajax或类似的事情,它将通过Ajax调用页面,并发送所有形式为 orderproductForm 的输入。 我想一种方法是做类似的事情 jQuery.get("myurl", {action : document.orderproductForm.action.value, cartproductid : document.orderproductForm.cartproductid.value, productid : document.orderproductForm.productid.value, ... 但是我不完全知道所有的表格输入。 是否有仅发送所有表单输入的功能部件或功能? #1楼 使用在form元素上定义的属性的另一种类似解决方案: <form id="contactForm1" action="/your_url" method="post"> <!-- Form input fields here (do not forget your name attributes). --> </form> <script type="text/javascript"> var frm =