81,092
社区成员
发帖
与我相关
我的任务
分享
request.setAttribute("filepath",filepath);
RequestDispatcher view=request.getRequestDispatcher("/jfreeChart.jsp");
view.forward(request, response);
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
</head>
<body>
<div id="d1" style="display:none;">Wait a moment</div>
<input type="button" id="btn1" value="Submit"/>
</body>
<script>
$('#btn1').click(function () {
$.ajax({
type: "get",
url: "/ashx/Handler1.ashx",
dataType: "text",
beforeSend: function () {
$('#d1').show();
},
complete: function () {
$('#d1').hide();
},
success: function (data) {
alert(data);
}
});
})
</script>
</html>
handle1,假设使用了3秒来生成图片,并最后返回图片名称
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
Thread.Sleep(3000);
string filePath = "helloworld.jpg";
context.Response.StatusCode = (int)HttpStatusCode.OK;
context.Response.Write(filePath);
}
public bool IsReusable
{
get
{
return false;
}
}
}