SUN的《AJAX与J2EE》全文译了

2019-06-03 05:49:33王冬梅

  ——XMLHttpRequest对象调用callback()函数并处理结果。   

  The   XMLHttpRequest   object   was   configured   to   call   the   callback()   function   when   there   are   changes   to   the   readyState   of   the   XMLHttpRequest   object.   Let   us   assume   the   call   to   the   ValidateServlet   was   made   and   the   readyState   is   4,   signifying   the   XMLHttpRequest   call   is   complete.   The   HTTP   status   code   of   200   signifies   a   successful   HTTP   interaction.     
  ——XMLHttpRequest对象的准备状态有所变化的时候则调用callback()方法、我们假定已经请求完毕ValidateServlet、准备状态为4、表示XMLHttpRequest调用已经完成、HTTP状态码为200、表示HTTP交互已经成功。   

  function   callback()   {   
          if   (req.readyState   ==   4)   {   
                  if   (req.status   ==   200)   {   
                          //   update   the   HTML   DOM   based   on   whether   or   not   message   is   valid   
                  }   
          }   
  }   

  Browsers   maintain   an   object   representation   of   the   documents   being   displayed   (referred   to   as   the   Document   Object   Model   or   DOM).   JavaScript   technology   in   an   HTML   page   has   access   to   the   DOM,   and   APIs   are   available   that   allow   JavaScript   technology   to   modify   the   DOM   after   the   page   has   loaded.