出錯的原始代碼:
 1 var  factNo  =   " 0240 "
 2 var
 defaultDate; 
 3 var  endPoint  =   " <%=request.getContextPath()%>/bfapp "

 4 var  buffalo  =   new
 Buffalo(endPoint); 
 5 function  loadCexpbver()

 6     buffalo.remoteCall( " cexpbverService.listAll " , [],  function (reply)

 7          var  list  =
 reply.getResult(); 
 8         defaultDate  =  list[ 0
].updateDate; 
 9          var  strTable  =   " <table width=\ " 98 % \ "  cellpadding=\ " 3 \ "   "
 
10          +   " cellspacing=\ " 1 \ "  class=\ " TableBorderLight\ "
 
11 align=\ " center\ " > "
 
12          +   " <tr class=TableTitle><th>Update Date</th> "
 
13          +   " <th>User</th></tr> "

14          for  ( var  i = 0 ; i < list.length; i ++

15              var  className  =  (i % 2 == 0 ) ? " TableBodyLight " : " TableBodyDark "

16             strTable  +=   " <tr class= "   +
 className 
17              +   "  onclick=\ " loadCexpbodr(' "
 + list[i].updateDate 
18             +  " ')\ "  style=\ " cursor:pointer\ " > "
 
19              +   " <td align=center> "   +  formatDate(list[i].updateDate)  +
 
20 " </td> "
 
21              +   " <td> "   +  list[i].userNo  +   " </td> "
 
22              +   " </tr> "

23         }
 
24         strTable  +=   " </table> "

25          var  table  =  $ { " cexpbver " }

26         table.innerHTML  =
 strTable; 
27     }
); 
28

29

30 }
 
31

32

33 function  loadCexpbodr(ud)

34     buffalo.remoteCall( " cexpbodrService.findByUpdateDate "
, [factNo,ud], 
35 function (reply)

36          var  strTable  =   " <table width=\ " 98 % \ "  cellpadding=\ " 3 \ "   "
 
37          +   " cellspacing=\ " 1 \ "  class=\ " TableBorderLight\ "
 
38 align=\ " center\ " > "

39          var  list  =
 reply.getResult(); 
40          for  ( var  i = 0 ;i < list.length;i ++ )

41              var  className  =  (i % 2 == 0 ) ? " TableBodyLight " : " TableBodyDark "

42             strTable  +=   " <tr class= "   +  className  +   " ><td> "   +
 
43 list[i].partNo  +   " </td> "
 
44                  +   " <td> "   +  list[i].style  +   " </td> "
 
45                  +   " <td> "   +  list[i].width  +   " </td></tr> "

46         }
 
47         strTable  +=   " </table> "
 
48          var  table  =  $ { " cexpbodr " }

49         table.innerHTML  =
 strTable; 
50     }
); 
51 }
 
52

53 window.onload  =   function  ()

54
    loadCexpbver(); 
55
    loadCexpbodr(defaultDate); 
56 }
 
57


我的分析:

 如果把 window.onload 改為
window.onload = function (){
    loadCexpbver();
    alert(defaultDate);
    loadCexpbodr(defaultDate);
}
就不會出錯. 原因我已找到,應該是第一個Request的狀態還未完成時,就執行了第2個的原因,中間加行alert(defaultDate);實際上起到了延遲執行loadCexpbodr(defaultDate);的作用,所以不會報錯.

但是目前還不知道該如何解決?