Javascript TypeError:在未实现接口HtmleElement的对象上单击调用
我已经看到了关于这个主题的错误,但是我无法在我的代码中发现错误Javascript TypeError:在未实现接口HtmleElement的对象上单击调用,javascript,jquery,Javascript,Jquery,我已经看到了关于这个主题的错误,但是我无法在我的代码中发现错误 $('#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.al
$('#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\u action”]”)
应该是:
var action=$('select[name=“bulk_action”]”)。val()
你能引用一个JSIDLE吗?你能在$之前和之后添加调试器吗。每个fdata都让我们看到变量的实时变化。我是个该死的白痴,就是这样。这是操作
变量。它的值是一个jQuery对象,忘了对它调用val()
。我正在使用$.map()
构建一个值数组。而是构建一个jquery对象,这是我的ajax调用不喜欢的。谢谢你发布这些信息,否则我永远不会知道。