我看过 other questions关于这个主题,但我无法在我的代码中发现错误。
$('#submit_bulk').on('click',function(e){
var action = $('select[name="bulk_action"]'),
targets = $('table tr td:first-child :checkbox:checked');
if(action=='invalid' || targets.length == 0){
sk.alert('Nothing to do','warning');
return false;
}else{
$(this).html('Working....');
var fData = {
action: action,
mixtapes: '',
singles: ''
};
$.each(targets,function(i,v){
if($(this).data('type') == 'mixtape'){
fData.mixtapes += $(this).data('id')+',';
}else{
fData.singles += $(this).data('id')+',';
}
});
fData = $.param(fData);
console.log(fData); //i get no output here. is fData null?
$.post(window.location.origin+'/adminAPI/bulk_action',fData,function(data){
var data = JSON.parse(data);
if(data.error==0){
sk.alert('Your changes were saved','success');
//update view here.
}else{
sk.alert(data.message,'error');
}
});
$(this).html('go');
}
});
最佳答案
智者之言。确保您没有将 jQuery 选择器
作为值传递到您的表单数据中。
违规行是:
var action = $('select[name="bulk_action"]')
应该是:
var action = $('select[name="bulk_action"]').val()
关于javascript - 类型错误 : click called on object that does not implement interface HtmlElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31999793/