一个aspx页面,一个ashx页面,,怎么把ashx文件中的context.Response.Write("OK");传到前台的label显示啊?谢谢 public void ProcessRequest (HttpContext context) {
string json = "OK";
context.Response.Write(json); 需要把这个到前台显示!!
}
前台脚本
<script type="text/javascript">
// $(function () {
$("#txtContents").blur(function () {
$.post("Handler2.ashx", //要发送到的URL地址 以Post形式发送
{"name": $("#txtContents").attr("value"), "user_id": $("#TextBox1").attr("value") }, //发送的Json数据 _name 对应Home/getJsonData方法中的参数名字
function (data) //回调函数 参数data : 返回的json数据
{
l aert(data);
这里不弹出任何数据,貌似像是没返回任何数据一样
},
"json" //返回json类型数据
);
});
});
</script>
string json = "OK";
context.Response.Write(json); 需要把这个到前台显示!!
}
前台脚本
<script type="text/javascript">
// $(function () {
$("#txtContents").blur(function () {
$.post("Handler2.ashx", //要发送到的URL地址 以Post形式发送
{"name": $("#txtContents").attr("value"), "user_id": $("#TextBox1").attr("value") }, //发送的Json数据 _name 对应Home/getJsonData方法中的参数名字
function (data) //回调函数 参数data : 返回的json数据
{
l aert(data);
这里不弹出任何数据,貌似像是没返回任何数据一样
},
"json" //返回json类型数据
);
});
});
</script>
{"name": $("#txtContents").attr("value"), "user_id": $("#TextBox1").attr("value") }, //发送的Json数据 _name 对应Home/getJsonData方法中的参数名字
function (data) //回调函数 参数data : 返回的json数据
{
l aert(data);
这里不弹出任何数据,貌似像是没返回任何数据一样
},
"text" //去掉或者改为text或者html
);
type: "post",
dataType: "text",
url: 'Handler2.ashx',
data: { "name": $("#txtContents").val(), "user_id": $("#TextBox1").val() },
success: function (msg) {
var htmls = "<li>" + msg + "</li>";
$("#ulContent").append(htmls);
} });