我试图通过脚本标签调用 jQuery 和 PHP 文件的组合,但它没有正确加载。
这是我的代码
<script type="text/javascript">
jQuery(document).ready(function(){
$("#country").change(function(){
var getVal = $(this).val();
<?php $sql="select t.term_id,t.description,t2.name,t2.slug from wp_term_taxonomy as t join wp_terms as t2 on t.term_id=t2.term_id where t.parent=3";
$data=mysql_query($sql);
while($rec=mysql_fetch_array($data))
{?> if(getVal=="<?php echo $rec['name'];?>" )
{
window.location = "<?php echo get_category_link( $rec['term_id'] );?>";
} <?php }?>
});
$("#team").change(function(){
var getVal = $(this).val();
<?php
$args=array(
'orderby' => 'name',
'order' => 'ASC',
'taxonomy' => 'teams'
);
$categories=get_categories($args);
foreach($categories as $category) { ?>if(getVal=="<?php echo $category->name;?>"){
<?php $x=str_replace(' ','-',$category->name);
$y=str_replace('\'','',$x);?>
window.location = "<?php echo home_url( '/' );?>teams/<?php echo $y;?>";
}
<?php }?>
});
});
</script>