我试图在我的$ .get函数完成后执行一个动作,但我下面的代码不起作用。有人可以告诉我我做错了吗?
$.get('assets/php/paymentaccounts.php', function(data) {
$('#PaymentAccounts').html(data);
}).delay(400).queue(function(next){
var config = {
'.chosen-select' : {},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
'.chosen-select-width' : {width:"95%"}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
});
答案 0 :(得分:0)
$.get()
会返回一个承诺,它没有queue
方法。
在回调中添加队列,附加到jQuery对象,该对象具有queue
方法
$.get('assets/php/paymentaccounts.php', function(data) {
$('#PaymentAccounts').html(data).delay(400).queue(function(next){
var config = {
'.chosen-select' : {},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
'.chosen-select-width' : {width:"95%"}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
next();
});
});
答案 1 :(得分:-2)
你在10行丢失了分号。 http://jsfiddle.net/是你的朋友。