62,046
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if(ConUserTop())
Response.Write("1");
else
Response.Write("0");
Response.End();
}
$.ajax({
type: 'POST',
url: '/a.aspx',
data: { },
dataType: 'text',//注意这里
success: function (data) {
if(data=="1")
{
//隐藏或者显示
}
else
{
//隐藏或者显示
}
}
});
public static bool ConUserTop()
{
Model.users User_info;
BasePage bp = new BasePage(); ;
User_info = bp.GetUserInfo();
if (User_info != null)
{
return false;
}
return true;
}
我现在让这个函数返回一个true、一个false,然后ajax判断返回值再进行控件的显示和隐藏,
这是b.html的代码,请问这个的思路的ajax要怎么写呢?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<link href="/aspx/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$.ajax({
type: "Post",
url: "/indextop.aspx",
data: {},
dataType: "html",
success: function (date)
{
}
})
});
</script>
</head>
<body>
<div class="topMenu">
<div class="indexCont">
<div class="fr">
<ul id="tMenu" class="tW tmCont">
<li class="b1"><a id="logout" class="m5" href="index.aspx" style="color:red;">[注销]</a></li>
<li class="b2">
<a id="login" class="m5" href="aspx/login.aspx" style="color:red;">[登陆]</a>
<a id="register" class="m5" href="aspx/register.aspx" style="color:red;">[注册]</a>
<a id="UserCenter" class="m5" href="aspx/PerCenDefault.aspx">[会员中心]</a>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("<div>组织的菜单html</div>");
Response.End();
}
a.html
$.ajax({
type: 'POST',
url: '/a.aspx',
data: { },
dataType: 'html',
success: function (data) {
//把a.aspx页面返回的html 嵌入到某个元素内
$("#div").html(data);
}
});