1、案例
2、说明:当下拉框出现变化的时候触发ajax
$("#selectitem").change(function(){ var item = $("#selectitem").find("option:selected").text(); item = item.replace(" ","_"); if(item != 'Please select...') { document.getElementById("divcheckbox").innerHTML=""; $("#divcheckbox").load('<?php echo Yii::app()->request->baseUrl; ?>/admin/news/gettrendgraph/'+item); } var classify=$(this).val(); $("#selecttagtwo").html(""); $("#selecttagtwo").append("<option value='Please select...'>请选择...</option>"); $.ajax({ url:"<?php echo $this->createUrl('/admin/news/getcategorys')?>", type : "POST", data : {classify:classify}, error : function(){alert('Error loading PHP document');}, success: function(data){ var data=eval('('+data+')'); $.each(data,function(i){ $("#selecttagtwo").append("<option value="+data[i].id+">"+data[i].category_name+"</option>"); }); } }); });