关于aspx,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)
{

......

}

posted @ 2017-12-04 11:29  飘阳小果  阅读(975)  评论(0编辑  收藏  举报