asp.net后台调用前台js代码
时间:2010-12-21 来源:孤独者
后台C#代码如下:
private string categoryId = "0"; protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["categoryId"])) { categoryId = Request.QueryString["categoryId"]; } Page.ClientScript.RegisterStartupScript(this.GetType(), "", "load("+categoryId+")", true); }
前台js代码如下:
function load(categoryId) { $.ajax({ type: "get", url: '<%=ResolveUrl("~/Componects/FriendLink.ashx") %>', dataType: "json", data:"categoryId="+categoryId, success: function (result) { $.each(result, function (index, data) { }); } }); };
相关阅读 更多 +