网上写的函数节流没怎么看懂
http://web.jobbole.com/86710/
自己写了一个非常简单的,也蛮好用的。
function getVal() {
window.setTimeout(
function () {
if (Ext.getCmp("enterprise_id").rawValue == val) {
<span style="white-space:pre"> </span>//Ajax请求
Ext.Ajax.request({
url: "admin/api/bond/client",
method: "GET",
params: {name: val},
success: function (response, opts) {
var newStore = Ext.create("Ext.data.Store", {
fields: ['id', 'name'],
data: Ext.JSON.decode(response.responseText)
});
Ext.getCmp("enterprise_id").store = newStore
Ext.getCmp("enterprise_id").bindStore(newStore);
Ext.getCmp("enterprise_id").expand();
var contract = Ext.getCmp("contract_id");
contract.clearValue();
}
});
}
else {
getVal()
}
}, 1000);
};
getVal();