使用ajax发布表单,然后刷新整个表单

编程入门 行业动态 更新时间:2024-10-11 21:20:02
本文介绍了使用ajax发布表单,然后刷新整个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人可以帮助我,使用ajax发布表单,然后刷新整个表单, i我使用下面的ajax方法将表单发布到控制器,然后在控制器方法中保存数据并将去 重定向动作方法重新加载表单,我如何获得返回成功消息,下面是我的代码 视图中的代码 尝试{ var data = new FormData(this.form); $ .ajax({ url :/ CreateApplicationFromSearch / SaveAndCloseApplication,//注意:使用正确的操作名称 类型:POST, 数据:数据, processData:false, contentType:false, 成功:函数(响应){ if(response!= null&& response.success){ var ApplicantId =(response.Applicant_id); var ApplicationId =(response.Application_id); ModalDialogue(ApplicantId ,ApplicationId); alert(response.responseText); } }, 错误:功能(响应){ alert(error!+ response.responseText); } }); } catch(ex){alert(ex);控制器中的代码 [HttpPost] public ActionResult SaveApplication(tr_applications Application,string OfficeHolder_id, ?INT AccountDetail_Id,串contact_person_id,IEnumerable的< httppostedfilebase> specific_Item,IEnumerable的< httppostedfilebase> Position_Description,IEnumerable的< httppostedfilebase> Employment_Contract,IEnumerable的< httppostedfilebase> Invoices_PhonePower,IEnumerable的< httppostedfilebase> Lease_Rent, 的IEnumerable< httppostedfilebase> Travel_Itinerary ,IEnumerable< httppostedfilebase> Members_Travelling, IEnumerable< httppostedfilebase> not_profitletter,IEnumerable< httppostedfilebase> ; schoolletter,IEnumerable< httppostedfilebase> affiliatedletter, I枚举< httppostedfilebase> finanncialstatement,IEnumerable< httppostedfilebase>银行验证) { service.SaveApplication(Application,specific_Item,Position_Description, Employment_Contract,Invoices_PhonePower,Lease_Rent,Travel_Itinerary, Members_Travelling,Capital_Works,Covering_Letter,Resolution_ToApply, not_profitletter,schoolletter,affiliatedletter,finanncialstatement,bankverification, applicant_id,Applicant_Name); if(OfficeHolder_id!=) Applicant_Service.Update_ApplicationId_OfficeHolder(OfficeHolder_id,Application.application_id); if(AccountDetail_Id!= null&& AccountDetail_Id!= 0) Applicant_Service.Update_Account_ApplicantionId(Convert.ToInt32(AccountDetail_Id),Application.application_id); if(contact_person_id!=) Applicant_Service.Update_ApplicationID_Contacts(contact_person_id,Application.application_id); 返回RedirectToAction(EditApplication,new {Application.applicant_id,Application.application_id,OfficeHolder_id,AccountDetail_Id,contact_person_id }); } 我尝试了什么: 视图中的代码 尝试{ var data = new FormData(this.form); $ .ajax( { url:/ CreateApplicationFromSearch / SaveAndCloseApplication,//注意:使用正确的操作名称 类型:POST, 数据:data, processData:false, contentType:false, 成功:函数(响应){ if(响应!= null&& response.success){ var ApplicantId =(response.Applicant_id); var ApplicationId =(response.Application_id); ModalDialogue(ApplicantId ,ApplicationId); alert(response.responseText); } }, 错误:function(响应){ alert(error!+ response.responseText); } }); } catch(ex){alert(ex); } }

Hi can some one help me, post the form using ajax and then refresh the whole form , i am posting the form using below ajax method to controller, then in controller method save the data and will go the redirect action method to reload the form and how can i get return success message in below is my code code in view try { var data = new FormData(this.form); $.ajax({ url: "/CreateApplicationFromSearch/SaveAndCloseApplication", // NB: Use the correct action name type: "POST", data: data, processData: false, contentType: false, success: function (response) { if (response != null && response.success) { var ApplicantId = (response.Applicant_id); var ApplicationId = (response.Application_id); ModalDialogue(ApplicantId, ApplicationId); alert(response.responseText); } }, error: function (response) { alert("error!" + response.responseText); } }); } catch (ex) { alert(ex); } } code in controller [HttpPost] public ActionResult SaveApplication(tr_applications Application, string OfficeHolder_id, int? AccountDetail_Id, string contact_person_id, IEnumerable<httppostedfilebase>specific_Item, IEnumerable<httppostedfilebase> Position_Description, IEnumerable<httppostedfilebase> Employment_Contract,IEnumerable<httppostedfilebase> Invoices_PhonePower, IEnumerable<httppostedfilebase> Lease_Rent, IEnumerable<httppostedfilebase> Travel_Itinerary, IEnumerable<httppostedfilebase> Members_Travelling, IEnumerable<httppostedfilebase> Capital_Works, IEnumerable<httppostedfilebase> Covering_Letter, IEnumerable<httppostedfilebase> Resolution_ToApply, IEnumerable<httppostedfilebase> not_profitletter, IEnumerable<httppostedfilebase> schoolletter, IEnumerable<httppostedfilebase> affiliatedletter, IEnumerable<httppostedfilebase> finanncialstatement, IEnumerable<httppostedfilebase> bankverification) { service.SaveApplication(Application, specific_Item, Position_Description, Employment_Contract, Invoices_PhonePower, Lease_Rent, Travel_Itinerary, Members_Travelling, Capital_Works, Covering_Letter, Resolution_ToApply, not_profitletter, schoolletter, affiliatedletter, finanncialstatement, bankverification, applicant_id, Applicant_Name); if (OfficeHolder_id != "") Applicant_Service.Update_ApplicationId_OfficeHolder(OfficeHolder_id, Application.application_id); if (AccountDetail_Id != null && AccountDetail_Id != 0) Applicant_Service.Update_Account_ApplicantionId(Convert.ToInt32(AccountDetail_Id), Application.application_id); if (contact_person_id != "") Applicant_Service.Update_ApplicationID_Contacts(contact_person_id, Application.application_id); return RedirectToAction("EditApplication", new { Application.applicant_id, Application.application_id, OfficeHolder_id, AccountDetail_Id, contact_person_id }); } What I have tried: code in view try { var data = new FormData(this.form); $.ajax({ url: "/CreateApplicationFromSearch/SaveAndCloseApplication", // NB: Use the correct action name type: "POST", data: data, processData: false, contentType: false, success: function (response) { if (response != null && response.success) { var ApplicantId = (response.Applicant_id); var ApplicationId = (response.Application_id); ModalDialogue(ApplicantId, ApplicationId); alert(response.responseText); } }, error: function (response) { alert("error!" + response.responseText); } }); } catch (ex) { alert(ex); } }

推荐答案

.ajax({ url:/ CreateApplicationFromSearch / SaveAndCloseApplication,//注意:使用正确的操作名称 类型:POST, 数据:数据, processData:false, contentType:false, 成功:函数(响应){ if(response!= null&& response.success){ var ApplicantId =(response.Applicant_id); var ApplicationId =(response.Application_id); ModalDialogue(ApplicantId,ApplicationId); alert(response.responseText); } }, 错误:功能(响应){ alert(error!+ response.responseText); } }); } catch(ex){alert(ex) );控制器中的代码 [HttpPost] public ActionResult SaveApplication(tr_applications Application,string OfficeHolder_id, ?INT AccountDetail_Id,串contact_person_id,IEnumerable的< httppostedfilebase> specific_Item,IEnumerable的< httppostedfilebase> Position_Description,IEnumerable的< httppostedfilebase> Employment_Contract,IEnumerable的< httppostedfilebase> Invoices_PhonePower,IEnumerable的< httppostedfilebase> Lease_Rent, 的IEnumerable< httppostedfilebase> Travel_Itinerary ,IEnumerable< httppostedfilebase> Members_Travelling, IEnumerable< httppostedfilebase> not_profitletter,IEnumerable< httppostedfilebase> ; schoolletter,IEnumerable< httppostedfilebase> affiliatedletter, I枚举< httppostedfilebase> finanncialstatement,IEnumerable< httppostedfilebase>银行验证) { service.SaveApplication(Application,specific_Item,Position_Description, Employment_Contract,Invoices_PhonePower,Lease_Rent,Travel_Itinerary, Members_Travelling,Capital_Works,Covering_Letter,Resolution_ToApply, not_profitletter,schoolletter,affiliatedletter,finanncialstatement,bankverification, applicant_id,Applicant_Name); if(OfficeHolder_id!=) Applicant_Service.Update_ApplicationId_OfficeHolder(OfficeHolder_id,Application.application_id); if(AccountDetail_Id!= null&& AccountDetail_Id!= 0) Applicant_Service.Update_Account_ApplicantionId(Convert.ToInt32(AccountDetail_Id),Application.application_id); if(contact_person_id!=) Applicant_Service.Update_ApplicationID_Contacts(contact_person_id,Application.application_id); 返回RedirectToAction(EditApplication,new {Application.applicant_id,Application.application_id,OfficeHolder_id,AccountDetail_Id,contact_person_id }); } 我尝试了什么: 视图中的代码 try { var data = new FormData(this.form); .ajax({ url: "/CreateApplicationFromSearch/SaveAndCloseApplication", // NB: Use the correct action name type: "POST", data: data, processData: false, contentType: false, success: function (response) { if (response != null && response.success) { var ApplicantId = (response.Applicant_id); var ApplicationId = (response.Application_id); ModalDialogue(ApplicantId, ApplicationId); alert(response.responseText); } }, error: function (response) { alert("error!" + response.responseText); } }); } catch (ex) { alert(ex); } } code in controller [HttpPost] public ActionResult SaveApplication(tr_applications Application, string OfficeHolder_id, int? AccountDetail_Id, string contact_person_id, IEnumerable<httppostedfilebase>specific_Item, IEnumerable<httppostedfilebase> Position_Description, IEnumerable<httppostedfilebase> Employment_Contract,IEnumerable<httppostedfilebase> Invoices_PhonePower, IEnumerable<httppostedfilebase> Lease_Rent, IEnumerable<httppostedfilebase> Travel_Itinerary, IEnumerable<httppostedfilebase> Members_Travelling, IEnumerable<httppostedfilebase> Capital_Works, IEnumerable<httppostedfilebase> Covering_Letter, IEnumerable<httppostedfilebase> Resolution_ToApply, IEnumerable<httppostedfilebase> not_profitletter, IEnumerable<httppostedfilebase> schoolletter, IEnumerable<httppostedfilebase> affiliatedletter, IEnumerable<httppostedfilebase> finanncialstatement, IEnumerable<httppostedfilebase> bankverification) { service.SaveApplication(Application, specific_Item, Position_Description, Employment_Contract, Invoices_PhonePower, Lease_Rent, Travel_Itinerary, Members_Travelling, Capital_Works, Covering_Letter, Resolution_ToApply, not_profitletter, schoolletter, affiliatedletter, finanncialstatement, bankverification, applicant_id, Applicant_Name); if (OfficeHolder_id != "") Applicant_Service.Update_ApplicationId_OfficeHolder(OfficeHolder_id, Application.application_id); if (AccountDetail_Id != null && AccountDetail_Id != 0) Applicant_Service.Update_Account_ApplicantionId(Convert.ToInt32(AccountDetail_Id), Application.application_id); if (contact_person_id != "") Applicant_Service.Update_ApplicationID_Contacts(contact_person_id, Application.application_id); return RedirectToAction("EditApplication", new { Application.applicant_id, Application.application_id, OfficeHolder_id, AccountDetail_Id, contact_person_id }); } What I have tried: code in view try { var data = new FormData(this.form);

.ajax({ url:/ CreateApplicationFromSearch / SaveAndCloseApplication,// NB:使用正确的操作名称 类型:POST, 数据:数据, processData:false, contentType:false, 成功:函数(响应){ if(response!= null&& response.success){ var ApplicantId =(response.Applicant_id); var ApplicationId =(response.Application_id); ModalDialogue(ApplicantId ,ApplicationId); alert(response.responseText); } }, 错误:function(响应){ alert(error!+ response.responseText); } }); } catch(ex){alert(ex); } } .ajax({ url: "/CreateApplicationFromSearch/SaveAndCloseApplication", // NB: Use the correct action name type: "POST", data: data, processData: false, contentType: false, success: function (response) { if (response != null && response.success) { var ApplicantId = (response.Applicant_id); var ApplicationId = (response.Application_id); ModalDialogue(ApplicantId, ApplicationId); alert(response.responseText); } }, error: function (response) { alert("error!" + response.responseText); } }); } catch (ex) { alert(ex); } }

更多推荐

使用ajax发布表单,然后刷新整个表单

本文发布于:2023-10-12 05:04:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483789.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!