分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

关于aspx,js前后台交互相关

发布时间:2023-09-06 01:28责任编辑:郭大石关键词:js

① aspx中嵌入后台处理代码,用<%   %>

例1:

<div class="panel-body leftPbody">
???????????????????????????<div class="panel-group" id="accordion">
???????????????????????????????<% Response.Write(strListHtml); %>
???????????????????????????</div>
???????????????????????</div>

例2:

<span id="LPCourse_ID"><%=strCourse_ID%></span>

②在js中需要访问后台,借助ajax

function getAjax(url, parm, callBack) {
???$.ajax({
???????type: ‘post‘,
???????dataType: "text",
???????url: url,
???????data: parm,
???????cache: false,
???????async: false,
???????success: function (msg) {
???????????callBack(msg);
???????}
???});
}

function GetVideo(x, y) {
???var parm = ‘action=aaaa‘;
???parm = parm + ‘&A=‘ + x;
???getAjax(‘ashx/oo.ashx‘, parm, function (rs) {
???????try {
???????????if(rs=="")
???????????{
.......
???????????}
???????????else
???????????{
????????????????......
???????????}

ashx/oo.ashx:

public class oo: IHttpHandler, IRequiresSessionState
???{
???????public void ProcessRequest(HttpContext context)
???????{
???????????context.Response.ContentType = "text/plain";
???????????context.Response.Buffer = true;
???????????context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
???????????context.Response.AddHeader("pragma", "no-cache");
???????????context.Response.AddHeader("cache-control", "");
???????????context.Response.CacheControl = "no-cache";
???????????string Action = context.Request["action"]; ?//提交动作
???????????switch (Action)
???????????{

......

}

关于aspx,js前后台交互相关

原文地址:http://www.cnblogs.com/piaoyangguoguo/p/7976298.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved