摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Ajax-注冊(cè)驗(yàn)證</title> </head> <body> <p>郵箱: <input type=&
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Ajax-注冊(cè)驗(yàn)證</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)失去焦點(diǎn)時(shí)進(jìn)行驗(yàn)證 $(':input').blur(function() { $.ajax({ //請(qǐng)求 url: 'regsever.php', //請(qǐng)求類(lèi)型 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("恭喜您:注冊(cè)成功!") }) </script> </html>
批改老師:韋小寶批改時(shí)間:2019-03-06 09:14:13
老師總結(jié):ajax的驗(yàn)證還是蠻簡(jiǎn)單的 簡(jiǎn)單但是很重要 課后一定要多去練習(xí)哦