In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Ajax submit form data to the storage of the overall operation process, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article hope you can solve this problem.
* in the php project, when we want to write to the database, sometimes the code does not prevent sql injection, resulting in a variety of unpredictable errors *
This is a very simple registration page l I am submitting data in the form of ajax
The copy code is as follows:
RegisterForm
This is a test form!
User:
Ages:
Pass:
Addr:
Email:
Loading.
Body {text-align:center;}
.error {color:red;}
.tb {margin:0 auto;width:350px;height:200px;text-align:center;}
.tdleft {width:150px;text-align:left;}
$("# but") .click (function () {
Var name = $.trim ($("# name") .val ())
Var ages = $.trim ($("# ages") .val ())
Var pn = / ^\ dflowers /
Var addr = $.trim ($("# addr") .val ())
Var pass = $.trim ($("# password") .val ())
Var email = $.trim ($("# email") .val ())
Var reg = / ^ [a-zA-Z0-9 _] + @ [a-zA-Z0-9 _] + (\. [a-zA-Z] +) + $/ gi
If (name.length==0) {
Alert ("Please fill in your name carefully!"); return false
}
If (ages.length==0) {
Alert ("Please fill in your age!"); return false
}
If (! pn.test (ages)) {
Alert ("Please fill in the valid number!"); return false
}
If (pass.length==0 | | pass.length > 6) {
Alert ("Please fill in the password carefully!"); return false
}
If (addr.length==0) {
Alert ("Please fill in the address carefully"); return false
}
If (email.length==0) {
Alert ("Please fill in the email carefully!"); return false
}
If (! reg.test (email)) {
Alert ("email detection failed"); return false
}
Var send = {'name':name,'ages':ages,'pass':pass,'addr':addr,'email':email}
$.post ('_ process.php',send,function (data) {
If (data.res==-1) {
$("# result") .addClass ("error")
}
$("# result") .html (data.msg)
/ / $("form") [0] .reset ()
}, 'json')
})
$("# msg") .ajaxStart (function () {
(this) .fadeIn ()
}) .ajaxStop (function () {
(this) .fadeOut ()
})
File that receives the data submitted by ajax and does related processing
The copy code is as follows:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.