瀏覽代碼

Listing 6.21. Replacing $(foo).load() by $.ajax().

Frederic G. MARAND 9 年之前
父節點
當前提交
ccb09fb54f
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      Chapter 6/06.js

+ 5 - 2
Chapter 6/06.js

@@ -3,8 +3,11 @@ $(document).ready(function () {
 
   $('#letter-a a').click(function (event) {
     event.preventDefault();
-    $('#dictionary').hide().load('a.html', function () {
-      $(this).fadeIn();
+    $.ajax({
+      url: 'a.html',
+      success: function (data) {
+        $('#dictionary').html(data);
+      }
     });
   });