Farewell Ajax implementation No Refresh submit Form _ Experience Exchange

Source: Internet
Author: User

Often, we use Ajax to implement a form that is not refreshed. Some time ago I followed the boss. Another way of not refreshing a submit form. Now put it out and share it with everyone.

First type:

(HTML page)

Copy Code code as follows:

<! DOCTYPE html>
<meta charset= "Utf-8" >
<title> No refresh submission Form </title>
<style type= "Text/css" >
ul{List-style-type:none;}
</style>
<body>
<iframe name= "Formsubmit" style= "Display:none;" >
</iframe>

<!--point the window submitted by form to the hidden Ifrmae and submit the data through Ifrmae. -->
<form action= "form.php" method= "POST" name= "formphp" target= "Formsubmit" >
<ul>
<li>
<label for= "uname" > Username:</label>
<input type= "text" name= "uname" id= "uname"/>
</li>
<li>
<label for= "pwd" > Password:</label>
<input type= "password" name= "pwd" id= "pwd"/>
</li>
<li>
<input type= "Submit" value= "Login"/>
</li>
</ul>
</form>
</body>

(PHP page)

Copy Code code as follows:

<?php
Non-null validation
if (Empty ($_post[' uname ')) | | | empty ($_post[' pwd '])
{
Echo ' <script type= "Text/javascript" >alert ("NULL username or password!"); </script> ';
Exit
}

Verify Password
if ($_post[' uname ']!= ' Jack ' | | $_post[' pwd ']!= ' 123456 ')
{
Echo ' <script type= "Text/javascript" >alert ("Incorrect username or password!"); </script> ';
Exit
} else {
Echo ' <script type= "Text/javascript" >alert ("Login successful!"); </script> ';
Exit
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.