JQuery regularly reads and analyzes XML files

From , 3 Years ago, written in JavaScript, viewed 193 times.
URL https://pastebin.vip/view/a62178a8
  1. //xml文件如下
  2. <?xml version="1.0"?>
  3. <data>
  4.     <page tasks="1" messages="3" notifications="3"/>
  5. </data>
  6.  
  7. $(document).ready(function() {
  8.     function get_info() {
  9.         $.ajax({
  10.             type: "GET",
  11.             url: "page.xml",
  12.             dataType: "xml",
  13.             cache: false,
  14.             complete: function(doc) {
  15.                 var tasks = $(doc.responseText).find("page").attr("tasks");
  16.                 var msgs = $(doc.responseText).find("page").attr("messages");
  17.                 var notes = $(doc.responseText).find("page").attr("notifications");
  18.                 if (tasks != $('#tasks').text() ||
  19.                     msgs != $('#messages').text() ||
  20.                     notes != $('#notifications').text()) {
  21.                     document.title = "Facebook" + ' NEW NOTIFICATON';
  22.                 }
  23.                 $('#tasks').text(tasks);
  24.                 $('#messages').text(msgs);
  25.                 $('#notifications').text(notes);
  26.             }
  27.         });
  28.  
  29.     }
  30.     setInterval(function() {
  31.         get_info();
  32.     }, 5000);
  33. });
  34. //javascript/2140

Reply to "JQuery regularly reads and analyzes XML files"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website