搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
jQuery 教程
jQuery Ajax
源代码
清空
点击运行
<!DOCTYPE html> <html> <title>jQuery Ajax 本地事件示例 - 基础教程(div.cn)</title> <head> <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.ajax({ url: "ajax_intro.txt", beforeSend: function(){ $("p").append("触发beforeSend事件<br>"); }, error: function(xhr){ $("p").append("发生错误: " + xhr.status + " " + xhr.statusText + "<br>"); }, success: function(response){ $("p").append(response); }, complete: function(){ $("p").append("触发complete事件<br>"); } }); }); }); </script> </head> <body> <h2>jQuery Ajax 本地事件</h2> <button>加载"ajax_intro.txt"</button> <p></p> </body> </html>
运行结果