In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to implement the ajax submission form form in php. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Php to achieve ajax to submit form forms: 1, create a HTML and PHP files and create form forms; 2, through the "$.ajax ({type:" post ", url:" text7.php ", data:dataString...})" code to submit the form.
This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.
How to implement ajax to submit form form in php?
Submit form forms through php jq ajax
The code is as follows:
Html
Name is required, your Email is required, your contact number is required
Js
$(function () {$(".error") .hide (); $(".button") .click (function () {var name= $("# name") .val (); if (name== "") {$("# name_error") .show (3600); $("# name_error") .focus (); return false / / the function of return false is to make the input box effect appear only one at a time / / when type is submit, the form form will be submitted without return false, but there will be no effect / / when type is button, the effect can be displayed without return false / / original words: but only when there is an error, that is, empty, the error will occur. Because of the role of return false, only one error occurs at a time. } var email= $("# email"). Val (); if (email== ") {$(" # email_error "). Show (3600); $(" # email_error "). Focus (); return false;} var phone= $(" # phone "). Val () If (phone== ") {$(" # phone_error ") .show (3600); $(" # email_error ") .focus (); return false;} var dataString = 'name='+ name +' & email=' + email +'& phone=' + phone; / / [xss_clean] (dataString) $.ajax ({type: "post", url: "text7.php", data:dataString, success:function (mag) {/ / alert (mag); return / / ajax cannot see the postvalue in the form form php, so it can only be printed in the callback function. The following is the return effect of $('# contact_form'). Html ("); $(" # message ") .html ("
Contact information has been successfully submitted!
") .append ("
Script design
") .hide () .fadeIn (1500, function () {$('# message') .append ("
");});}}) return false;})})
Php
Print_r ($_ POST); echo $_ POST ['name'].'
Die; on how to implement the ajax submission form form in php is shared here. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
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.