跪求一段数据加载等待JQuery
如题! 要异步的!本人在网上找了好多就那么一两句代码,也不知道是不是!希望各位同志能够慷慨的发给我!谢谢!!!
------解决方案--------------------
直接粘贴为x.aspx
<%@ Language="C#" %>
<script runat="server">
public string GetData()
{
return DateTime.Now.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["ajax"] != null)
{
Response.Clear();
System.Threading.Thread.Sleep(6000);
Response.Write(GetData());
Response.End();
return;
}
}
</script>
<script src="jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#x").html("正在加载%………………");
$.ajax({
type: "GET",
url: "<%=Request.FilePath%>?ajax=1",
success: function (result) {
$("#x").html(result);
},
error: function (result) {
$("#x").html(result.responseText);
},
});
});
</script>
<div id="x"></div>