Home > Web Front-end > JS Tutorial > Two implementation methods of jquery ajax submitting form data_jquery

Two implementation methods of jquery ajax submitting form data_jquery

WBOY
Release: 2016-05-16 18:28:14
Original
966 people have browsed it

Previously, AJAX was implemented using Javascript scripts one by one, which was very cumbersome. After learning Jquery, I feel that implementing AJAX is not that difficult. Of course, in addition to the Jquery framework, there are other excellent frameworks. Here I will focus on the more popular Jquery. There are two ways to submit a form in Jquery AJAX, one is to submit data via url parameter, and the other is to submit form (as usual, the value of the Form form can be obtained in the background). In the form to be submitted, if there are many elements, it is recommended to submit in the second way. Of course, if you want to practice your "typing skills", it is not a bad idea to submit in the first way. I believe developers don't want to waste their efforts. ! Without further ado, I’ll post an example.
First of all, download the two plug-ins Jquery and Jquery.form, there are many online!
1: Url parameter submission data

Copy code The code is as follows:




Backend code:
Copy code The code is as follows:

if(context. Request.Params["ID"].ToString()!="")
{
Pxt.Logic.SYS.CORP_BASE_INFO cbiL = new Pxt.Logic.SYS.CORP_BASE_INFO();
bool flag= cbiL.checkCorpID(context.Request.Params["ID"].ToString());
if (flag)
{
context.Response.Write("This customer number has been occupied!") ;
}
else
{
context.Response.Write("This customer number is available!");
}
}

Two: Form submits data
Front-end code:
Copy code The code is as follows:

//Must quote
//Must quote












< ;td width="30%" class="tableBg1">Return visit topic:



























Customer return visit
Customer name:
< ;asp:TextBox ID="txtF_CorpName" runat="server">


Contact:

Contact person title:< ;/td>



Contact number:

Return visit time:

Return visit content:

Return visit related documents:
< /asp:TextBox>



< ;input type="reset" class="button" value="Restore" />







Backend code :

Copy code The code is as follows:

protected void Page_Load(object sender, EventArgs e)
{
{
if (Request.QueryString["flag"] != null && Request.QueryString["flag"].ToString() == "do")
{
Pxt.Logic.DBRec.ReturnVisit bll = new Pxt.Logic.DBRec.ReturnVisit();
if (bll.Add(model(0)) > 0)
{
Response.Write("操作成功!");
Response.End();
}
}
}
}
/**////
/// 根据不同需要,设定模型->获取模型
///

/// ID值
///
private Pxt.Model.DBRec.ReturnVisit model(int id)
{
//获取表单值
string F_CorpName = Request.Form["txtF_CorpName"].ToString();
string F_ReturnVisitTitle = Request.Form["txtF_ReturnVisitTitle"].ToString();
string F_ContractPerson = Request.Form["txtF_ContractPerson"].ToString();
string F_ContractPersonPosition = Request.Form["txtF_ContractPersonPosition"].ToString();
string F_ContractPhone = Request.Form["txtF_ContractPhone"].ToString();
DateTime F_ReturnVisitDate = DateTime.Parse(Request.Form["txtF_ReturnVisitDate"].ToString());
string F_ReturnVisitContent = Request.Form["txtF_ReturnVisitContent"].ToString();
string F_ReturnVisitFile = Request.Form["txtF_ReturnVisitFile"].ToString();
string Refer = Session["username"].ToString();
DateTime DoTime = DateTime.Now.Date;
Pxt.Model.DBRec.ReturnVisit model = new Pxt.Model.DBRec.ReturnVisit();
if (id > 0)//修改记录,否则表示增加记录
{
model.ID = id;
}
model.F_CorpName = F_CorpName;
model.F_ReturnVisitTitle = F_ReturnVisitTitle;
model.F_ContractPerson = F_ContractPerson;
model.F_ContractPersonPosition = F_ContractPersonPosition;
model.F_ContractPhone = F_ContractPhone;
model.F_ReturnVisitDate = F_ReturnVisitDate;
model.F_ReturnVisitContent = F_ReturnVisitContent;
model.F_ReturnVisitFile = F_ReturnVisitFile;
model.Refer = Refer;
model.DoTime = DoTime;
return model;
}

注:Jquery.form是Jquery用于帮助操作表单的一个插件,具体的去网上看看教程!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template