Przeglądaj źródła

Listing 6.10: $.get() with a query.

Frederic G. MARAND 9 lat temu
rodzic
commit
03cddf7b18
1 zmienionych plików z 9 dodań i 1 usunięć
  1. 9 1
      Chapter 6/06.js

+ 9 - 1
Chapter 6/06.js

@@ -42,7 +42,7 @@ $(document).ready(function () {
     event.preventDefault();
     $.get('d.xml', function (data) {
       $('#dictionary').empty();
-      $(data).find('entry:has(quote[author])').each (function () {
+      $(data).find('entry').each(function() {
         var $entry = $(this);
         var html = '<div class="entry">';
         html += '<h3 class="term">' + $entry.attr('term');
@@ -70,4 +70,12 @@ $(document).ready(function () {
       });
     });
   });
+
+  $('#letter-e a').click(function (event) {
+    event.preventDefault();
+    var requestData = { term: $(this).text() };
+    $.get('e.php', requestData, function (data) {
+      $('#dictionary').html(data);
+    });
+  });
 });