前台代码
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="loginleft.css" rel="stylesheet" type="text/css" />
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#div1 ul li').click(function () {
var aa = $(this).text();
$.ajax({
type: "post",
contentType: "application/json",
url: "loginleft.aspx/Asd",
data: "{aa:'" + aa + "'}",
success: function (result) {
alert(result.d);
}
})
// $('#Label1').text(aa);
// alert($('#Label1').text());
});
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="div1">
<ul>
<li style="background-image: url(images/首页左导航背景.gif)">全部分类</li>
<li>移动开发</li>
<li>Web前端</li>
<li>架构设计</li>
<li>编程语言</li>
<li>互联网</li>
<li>数据库</li>
<li>系统运维</li>
<li>云计算</li>
<li>研发管理</li>
<li>综合</li>
</ul>
</div>
<div id="div2">
</div>
</form>
</body>
</html>
后台cs代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
namespace CSDN博客
{
public partial class loginleft : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string Asd(string aa)
{
return aa;
}
}
}