jquery ajax 三级联动菜单问题

我用PHP+jquery+mysql学了一个三级联动的下拉菜单怎么解决把网站挂在网上的因为网速的问题二影响这个下拉菜单... 我用PHP+jquery+mysql 学了一个 三级联动的下拉菜单 怎么解决把网站挂在网上的 因为网速 的问题二影响 这个下拉菜单 展开
 我来答
ipadho
2011-09-21 · TA获得超过2.4万个赞
知道大有可为答主
回答量:2.4万
采纳率:0%
帮助的人:1.3亿
展开全部
php文件:
$sql="select * from tb_category where first!=''";
$result=$db->Execute($sql);
$firstcat=$db->GetArray($sql);
$smarty->assign("firstcat",$firstcat);
js文件

$(function(){
$("#arttype").change(function(){
var catid=$(this).val();
$.ajax({
type:"POST",
url:"second.php",
data:"catid="+catid,
success:function(ss)
{
$("#er").html(ss);
}
})
/*if($(this).val()==0)
{
$("#er").css("display","none");
}
else{
$("#er").css("display","block");
}*/
})
$("#second").change(function(){
var catid=$(this).val();
$.ajax({
type:"POST",
url:"third.php",
data:"catid="+catid,
success:function(rr){
$("#san").html(rr);
}
})
})
})

html文件:
<select name="arttype" id="arttype">
<option selected>---请选择--</option>

<option value=""></option>

</select>
<span id="er">

</span>
<span id="san"></span>

er.tpl文件:
<select name="second" id="second">
<option selected>---请选择--</option>

<option value=""></option>

</select>
也要引用js文件
san.tpl文件:
<select name="third" id="third">
<option selected>---请选择--</option>

<option value=""></option>

</select>引用js文件
third.php文件

include_once("smarty.php");
include_once("../conn.php");
$catid=$_POST['catid'];
$sql="select * from tb_category where parentid=".$catid;
$result=$db->Execute($sql);
$third=$db->GetArray($sql);
$smarty->assign("third",$third);
$smarty->display("san.tpl");

second.php文件:
header("Content-Type:text/html; charset=gb2312");
include_once("smarty.php");
include_once("../conn.php");
$catid=$_POST['catid'];
$sql="select * from tb_category where parentid='".$catid."'";
$result=$db->Execute($sql);
$second=$db->GetArray($sql);
$smarty->assign("second",$second);
$smarty->display("er.tpl");
Zerolone
2011-09-20 · 超过36用户采纳过TA的回答
知道小有建树答主
回答量:248
采纳率:0%
帮助的人:130万
展开全部
那可能是空间问题。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式