I am having the code with the below format.
PHP文件:
<form action="http://clientwebapi.com/createEvent" id="form_createEvent" method="post" enctype="multipart/form-data"> <input type="text" name="image_title" /> <input type="file" name="media" accept="image/*,video/*"/> </form>
JQUERY文件:
JQUERY file:
$('#form_createEvent').submit(function () { var form = $(this); $.ajax({ url: form.attr("action"), type: form.attr("method"), xhrFields: { withCredentials: true }, data: form.serialize() }).done(function () { showCurrentLocation(); alert('Event created successfully..'); location.reload(); }).fail(function () { alert("fail!"); }); event.preventDefault(); });
以上Jquery的code被提交。另外虽然我提出了下面的格式,它会重定向到 http://clientwebapi.com/createEvent 和事件成功创建。
The above Jquery code is submitting. Also While I am submitting the below format, It will redirect to the "http://clientwebapi.com/createEvent" and Event created successfully.
表单提交,并重定向到客户端页面:
Form Submit and redirect to client page:
$('#form_createEvent').submit(function () { var fd = new FormData(); fd.append('media', input.files[0]); $.ajax({ url: form.attr("action"), data: fd, processData: false, contentType: false, type: form.attr("method"), success: function (data) { alert(data); } }); event.preventDefault(); });
在这里,我怎么能prevent同时提交表单,并创建与给定图像的情况。好心帮
Here How can I prevent while submit the form and create the event with the given image. Kindly help
我找到了答案了这一点。我在这里做了一些错误。我用下面的code解决。
I found the Answer for this. I made some mistake here. I resolved by using the below code..
$('#form_createEvent').submit(function() { var form = new FormData($(this)[0]); $.ajax({ url: 'http://clientwebapi.com/createEvent/', type: 'POST', xhrFields: { withCredentials: true }, async: false, cache: false, contentType: false, processData: false, data: form, beforeSend: function () { $("#output_process").html("Uploading, please wait...."); }, success: function () { $("#output_process").html("Upload success."); }, complete: function () { $("#output_process").html("upload complete."); }, error: function () { //alert("ERROR in upload"); location.reload(); } }).done(function() { alert('Event created successfully..'); }).fail(function() { alert("fail!"); }); event.preventDefault(); });
相关推荐
协同反应(2023最新协同反应百科介绍)
云南省作家协会(2023最新云南省作家协会百科介绍)
官能的法则(2014年权七仁执导的喜剧电影)
金庆章(金庆章)
长林村(山西省长治市壶关县店上镇下辖村)
数字内容产业(信息技术与文化融合的产业形式)
钱仲鼎(钱仲鼎)
三达酒店(三达酒店)
湖北珠光宝气职业培训学校(湖北珠光宝气职业培训学校)
如何同时在一个布局并排在Android的不同看法播放多种视频文件排在
如何获得从意图的文件名?文件名、意图、如何获得
基于角色的安全asp.net的MVC角色、安全、asp、net
在C#赢形式的DateTimePicker限制的日期形式、日期、DateTimePicker
春天在哪里儿歌歌词_第一段:春天是四季之首
宝宝四个月辅食的做法_宝宝十一个月辅食食谱做法
让适合的瑜伽垫陪你健身_适合男生的增肌健身食谱的制作方法
白带呈黑色的原因是什么_白带呈黑色的原因
被紫外线晒伤怎么办呢_紫外线晒伤皮肤怎么办呢
皮肤淋巴细胞浸润症怎么办_皮肤淋巴细胞浸润症的治疗方法
原来这样用油才是正确的_怎样喝蜂蜜水才是正确的
最新文章
中国马术协会(2023最新中国马术协会百科介绍)
无主题变奏(2023最新无主题变奏百科介绍)
碳三(2023最新碳三百科介绍)
现代商业银行(中国工商银行长春金融研修学院主办的报刊)
流量互换(2023最新流量互换百科介绍)
韩国足球甲级联赛(2023最新韩国足球甲级联赛百科介绍)
星二代(2023最新星二代百科介绍)
联想乐园(联想乐园)
马腾(西北政法大学外国语学院副院长)
丁力学(丁力学)
吴青(代表作《怎样教初学者英语》)
如何改变数字选择器风格的Android?风格、数字、选择器、oid
有没有办法做到这一点,分配名单,其中内的值; T&GT; .ForEach()语句?这一
getLayoutInflater()的片段片段、getLayoutInflater
如何使用接触提供操作来更新接触式图像。如何使用、图像、操作
呼叫由被叫方拒绝
获得从枚举下一个N个元素元素
初始化程序语法初始化、语法、程序
什么是隐藏在服务器上的文件的最好方法是什么?器上、文件、方法
胃寒的人吃什么食物暖胃 胃寒的人别错过这8种暖胃食物_胃寒吃什么