ajax數(shù)據(jù)交互,常見的get、post、
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>ajax</title> <style type="text/css"> div{ width: 200px; margin: auto; } </style> </head> <body> <div> <h2>用戶驗證</h2> <label for="email">郵箱:</label> <input type="email" name="email" id="email"> <br> <label for="password">密碼:</label> <input type="password" name="password" id="password"> <br> <button>驗證</button> </div> </body> <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script type="text/javascript"> $('button').click (function(){ $.post( 'post.php?m=login', { "email": $('#email').val(), "password": $('#password').val() }, function(data){ if (data == '1') { alert('你好,你的賬號密碼正確') } else { alert('你好,你的賬號密碼不正確') } }) //禁用默認提交 return false }) </script> </html>
點擊 "運行實例" 按鈕查看在線實例
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號