http://jsbin.com/ezecun/edit#javascript,htmlonkeyup方式太慢
我必须这样写,因为它是动态制作的,下面列出的实际代码。我在jsbin中简化了一下。基本上它需要很长的时间来更新数组,使其不可用。
感谢您的关注。
CODE: PHP
echo "<label style='float:left'>Comments: </label> <textarea onKeyUp=\"editItemInCart(this.value,'comments',".$itemNum.")\" onChange=\"editItemInCart(this.value,'comments',".$itemNum.")\" >".$cart['comments']."</textarea><br />";
的JavaScript
function editItemInCart(newValue,fieldName,itemNum) {
jQuery.ajax({
type:"POST",
url: "editItem.html",
data: "newvalue=" + newValue + "&fieldname=" + fieldName + "&itemNum=" + itemNum,
})
//alert(newValue + fieldName + itemNum);
}
你对此有何看法? –
这不是关键事件,但脚本必须等待服务器响应AJAX查询。您是否测量了editItem.html处理查询需要多长时间? – JJJ
我希望它使用基于这两个事件的新值更新数组。 页面不到一秒钟,没问题。我认为在等待不活动的时候增加一个延迟,然后更新会更好,所以它不会一直发射。 – oneadvent