I'm using ajax post method for show result when select item. now i want get the items when the page loads but my code show result only when select an item i want show result from selected item when page load my ajax post code this is:
我在选择项目时使用ajax post方法显示结果。现在我想在页面加载时获取项目,但我的代码仅在选择项目时显示结果当我加载我的ajax邮政编码时,我想要显示所选项目的结果:
<script type="text/javascript" >
aaa = jQuery.noConflict();
function getItems(catid){
aaa.post('articles.php',{catid: catid},function(data){
aaa('#articlediv').html(data);}
);
}
</script>
<select type="list" name="categorylist" onChange="getItems(this.value)">
<?php
foreach($categoryid as $catid){
$title = modadcatarticlesHelper::getCatById($catid);
?>
<option value="<?php echo $catid ?>"><?php echo $title ?></option>
<?php } ?>
</select>
1 个解决方案
#1
0
try this,
<select type="list" name="categorylist" onChange="getItems(this.value)">
<?php
foreach($categoryid as $catid){
$title = modadcatarticlesHelper::getCatById($catid);
?>
<option value="<?php echo $catid ?>"><?php echo $title ?></option>
<?php } ?>
</select>
<script type="text/javascript" >
aaa = jQuery.noConflict();
function getItems(catid){
aaa.post('articles.php',{catid: catid},function(data){
aaa('#articlediv').html(data);}
);
}
window.onload = getItems('1');
</script>
#1
0
try this,
<select type="list" name="categorylist" onChange="getItems(this.value)">
<?php
foreach($categoryid as $catid){
$title = modadcatarticlesHelper::getCatById($catid);
?>
<option value="<?php echo $catid ?>"><?php echo $title ?></option>
<?php } ?>
</select>
<script type="text/javascript" >
aaa = jQuery.noConflict();
function getItems(catid){
aaa.post('articles.php',{catid: catid},function(data){
aaa('#articlediv').html(data);}
);
}
window.onload = getItems('1');
</script>