嗯,这可能是一个简单的问题,但我已经找出了这个问题。我想在console.log
中显示复选框的值,以便我可以使用它来触发AJAX调用。但每个复选框的值是相同的(第一个)。console.log中复选框的显示值
我花了一些时间在谷歌和我为我读的那里,我应该把复选框在array
。但我似乎无法让它工作。这是我目前的代码。
<!-- Custom taxonomy checkboxes -->
<?php
$taxonomy = 'locatie';
$queried_term = get_query_var($taxonomy);
$terms = get_terms($taxonomy, 'slug='.$queried_term);
if ($terms) {
foreach($terms as $term) {
$name = $term->name;
echo "<div class='col-xs-12 col-sm-12 col-md-2 col-lg-2'>
<form id='location'>
<input class='checkIt' type='checkbox' value='".$name."' name='location' id='".$name."_id'> ".$name."
</form>
</div>";
}
}
?>
<!-- /Custom taxonomy checkboxes -->
$('.checkIt').change(function(e) {
var value = $(this).val();
$.post('../wp-content/themes/mysite/includes/search-team-wp.php',{value:value}, function(data){
$('#search_results_team').hide().fadeIn(1100);
$("#search_results_team").html(data);
console.log(value);
});
});
});
一切正常,即使是AJAX调用,除了console.log输出,所以我不能通过AJAX调用发送不同的值。任何帮助将非常好!
所以你能发布数据和事件成功运行的回调? – KornholioBeavis