abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Ajax-注冊驗證</title> </head> <body> <p>郵箱: <input type=&
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Ajax-注冊驗證</title> </head> <body> <p>郵箱: <input type="text"></p> <p>密碼: <input type="password"></p> <p><button>提交</button></p> </body> <script type="text/javascript" src="js/jquery-3.3.1.js"></script> <script type="text/javascript"> //當(dāng)失去焦點時進(jìn)行驗證 $(':input').blur(function() { $.ajax({ //請求 url: 'regsever.php', //請求類型 type: 'GET', //轉(zhuǎn)化為json格式 data: $('form:first').serializeArray(), //回調(diào) success: function(msg, status, xhr) { // console.log(msg) $('p span').empty() $('p').append($(msg)).css('font-size', '1.5em') } }) }) $('button:first').click(function() { alert("恭喜您:注冊成功!") }) </script> </html>
Correcting teacher:韋小寶Correction time:2019-03-06 09:14:13
Teacher's summary:ajax的驗證還是蠻簡單的 簡單但是很重要 課后一定要多去練習(xí)哦