代码如下:
实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>作业</title> <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> $(function() { $(':input').blur(function() { $.ajax({ url: 'api/demo.php', type: 'GET', data: $('form').eq(0).serializeArray(), success: function(msg, status, xhr) { $('p span').empty() $('p').append($(msg)) } }) }) }) </script> </head> <body> <h2>用户注册</h2> <form> <p>用户名: <input type="text" name="name"> </p> </form> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例