- 爱易网页
-
JavaSript
- Jquery 删除文件后页面数据没更新,该怎么处理
日期:2014-05-16 浏览次数:20346 次
Jquery 删除文件后页面数据没更新
代码:
<script type="text/javascript">
$(function () {
$("#divSCA a").click(function () {
var name = $(this).prev("a").children('img').attr("alt");
$.ajax({
url: "delimg.aspx",
data: "picname=" + name,
datatype: "json",
type: "GET",
contentType: "application/json; charset=utf-8",
success: function (data, textStatus) {
alert(data.result);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest);
}
});
});
});
</script>
<div id="divSCA">
<a href="KunLunUpFile.html">上传图片</a> <input type="button" value="关闭" onclick="closeDiv()" />
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4"
DataKeyField="Name">
<ItemTemplate>
<a href="#" onclick="SetTextChanged('<%#Eval("Name")%>')">
<img alt="<%#Eval("Name")%>" height="70" width="70" src='<%#"../../UFile/" +Eval("Name")%>' />
<br/><%#Eval("Name")%>
</a>
<a>删除</a>
</ItemTemplate>
</asp:DataList>
</div>
后台代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DirectoryInfo imagesfile = new DirectoryInfo(Server.MapPath("../../UFile/"));
DataList1.DataSource = imagesfile.GetFiles("*.*");//所有文件
DataList1.DataBind(); }
}
\\\\\\\\delimg.aspx 代码
protected void Page_Load(object sender, EventArgs e)
{
if (Request["picname"] != null)
{
Response.Clear();
Response.ContentType = "application/json";
String result = "success";
try
{
File.Delete(Server.MapPath(@"../../UFile/") + Request["picname"].ToString());
}
catch (Exception ee)
{
result = ee.Message;
}
Response.Write("{\"result\":\"" + result + "\"}");
Response.End();
}
}
文件删除了,可是 页面上没有及时更新
而且弹出的结果是:undefined
请问这是怎么回事呢?
------解决方案--------------------
------解决方案--------------------