使用Ajax Prototype更新表上的数据

时间:2011-11-11 02:44:58

标签: javascript html ajax prototypejs

我正在使用PrototypeJS为我的项目,我使用Ajax.PeriodicalUpdater,实时插入我想要的,但它不替换我的表中的数据这里是HTML代码

<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th id="products"></th>
  </tr>
</table>

这是js的代码

new Ajax.PeriodicalUpdater('products', 'test.php',
  {
    method: 'get',
    insertion: Insertion.Top,
    frequency: 1,
    decay: 1
  }
);

但结果很糟糕,它每次添加和添加相同的数据,它不会替换,我做错了什么?

1 个答案:

答案 0 :(得分:2)

嗯,你正在插入,所以它......插入。

仅供参考,Insertion.Top is deprecated支持Element#insert,但你想要的是Element#replace

但是,默认是要替换的 - 通过指定一个insertion属性来覆盖默认值。有关详细信息,请参阅Updater docs