$('document').ready(function(){
var catid, action, data, selectid;
$('select.cat-selector').on('change', function() {
catid = $(this).val();
action = 'getsubcatbyidList';
data = { action: action, catid: catid };
$('#input-catid').val(catid);
// Sub Category
getsubcat(catid,action,"");
});
$('select.sub-category').on('change', function() {
$selectid = $(this).find('option:selected');
var id = $selectid.val();
$('#input-subcatid').val(selectid);
});
});
Ajax函数getsubcat(catid,action,"");
function getsubcat(catid,action,selectid){
var data = { action: action, catid: catid, selectid : selectid };
$.ajax({
type: "POST",
url: ajaxurl+'?action='+action,
data: data,
success: function(result){
if (result !== '') {
$(".subcategory").html(result);
}
}
});
$('*[data-ajax-catid='+catid+']').addClass('link-active');
$('button').prop('disabled', false);
}
和HTML
<form method="post">
<div class="btn-section">
<input type="text" id="input-catid" name="catid" value="">
<input type="text" id="input-subcatid" name="subcatid" value="">
<button type="submit" name="choose-category" id="next-btn" class="btn btn-primary text-caps" disabled>Proceed</button>
</div>
</form>
以上代码处理此任务,选择使用Cat ID的类别,并且还存储在隐藏的输入标记中,提取子类别和选择子类别,它应该获取子类别ID,但它没有&# 39;工作。我如何处理这些Bug,Jquery问题?我需要你的帮助