js的Ajax删除数据成功后当前页面的数据刷新不出来。求一个解决方案。

解决方案 »

  1.   

    ?????
    是不是 用了ajax的无刷新  然后删除数据后 不刷新了 也就是说 删除后更新不了是嘛?
      

  2.   

    是利用Ajax传数据到另外一个页面删除了数据,然后在调用Ajax来重新获取数据库的数据innerHTML到一个div里面。但是这个时候数据还是原来的数据,刷新不过来。除非是重新打开这个页面数据才会刷新的过来。
      

  3.   

    ajax与gridview结合无刷新新增、修改、删除数据的asp.net例子http://topic.csdn.net/u/20081215/16/fc6be5f1-bbed-403e-9864-6dd132294d20.html
    http://inezha.com/p/5058320/item4402
      

  4.   

    http://blog.csdn.net/ws_hgo/archive/2010/01/05/5137364.aspx
      

  5.   

     ProductBLL ProductInfo = new ProductBLL();   
        int ID;   
        ProductCategoryBLL Category = new ProductCategoryBLL();   
        protected int hit = 1;   
        string Name = string.Empty;   
        string Title = string.Empty;   
        protected string CategoryInfo;   
        protected string TitleKey;   
        string ModifyTime;   
        protected string Content = string.Empty;   
        protected string ParentTitle = string.Empty;   
      
        InfoBLL InfoMethod = new InfoBLL();   
        protected string Keyword;   
        protected string Pic;   
        protected string PictureUrl;   
        protected string Price = string.Empty;   
        string MemberName = string.Empty;   
      
        CommentsBLL CommentMethod = new CommentsBLL();   
        Comments Comment = new Comments();     
           
        protected void Page_Load(object sender, EventArgs e)   
        {   
            AjaxPro.Utility.RegisterTypeForAjax(GetType());   
              
            ID = FormUtil.GetQueryInt("ID");   
      
            DataTable DT = Category.GetDataByID(ID, "laozhuangProduct");   
      
            if (DT.Rows.Count > 0)   
            {   
                Title = DT.Rows[0][1].ToString();   
                ModifyTime = Convert.ToDateTime(DT.Rows[0][2].ToString()).ToShortDateString();   
                Content = DT.Rows[0][11].ToString();   
                PictureUrl = DT.Rows[0][12].ToString();   
                hit += Convert.ToInt32(DT.Rows[0][14].ToString());   
                Price = DT.Rows[0]["Keyword"].ToString();   
                Category.Update(ID, "laozhuangProduct", hit);   
                ParentTitle = Category.GetTitle(Convert.ToInt32(DT.Rows[0][15].ToString()), "laozhuangProductCategory");   
            }   
            MemberName = FormUtil.GetCookieString("Member");   
            if (MemberName.Equals(""))   
            {   
                MemberName = "匿名用户";   
            }   
            ShowTitle();   
        }   
        public void ShowTitle()   
        {   
            DataTable Dt = InfoMethod.GetDataByID(1, "laozhuangInfo");   
            if (Dt.Rows.Count > 0)   
            {   
                Keyword = Dt.Rows[0][1].ToString();   
            }   
        }   
        [AjaxPro.AjaxMethod]   
        public int Num(string Results)   
        {   
            int i=0;   
            string User = string.Empty;   
            string Mail = string.Empty;   
            string rank = string.Empty;   
            string r = string.Empty;   
            string Content = string.Empty;   
            string tit = string.Empty;   
            int pid = 0;   
            string[] str = Results.Split(',');   
            if(str.Length>0)   
            {   
                User = str[0].ToString();   
                Mail = str[1].ToString();   
                rank = str[2].ToString();   
                Content = str[3].ToString();   
                pid = int.Parse(str[4].ToString());   
                tit = str[5].ToString();   
            }   
             
            switch (r)   
            {    
                case "0":   
                    rank = "images/stars.gif";   
                    break;   
                case "1":   
                    rank = "images/stars1.gif";   
                    break;   
                case "2":   
                    rank = "images/stars2.gif";   
                    break;   
                case "3":   
                    rank = "images/stars3.gif";   
                    break;   
                case "4":   
                    rank = "images/stars4.gif";   
                    break;   
                default:   
                      rank = "images/stars5.gif";   
                    break;   
            }   
            Comment.MemberName = User;   
            Comment.EMail = Mail;   
            Comment.Keyword = rank;   
            Comment.Description = Content;   
            Comment.ProductID = pid;   
            Comment.Title = tit;   
            if (CommentMethod.Insert(Comment, "") > 0)   
            {   
                i = 1;   
            }   
            else  
            {   
                i = 0;   
            }   
            return i;   
        }   本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ws_hgo/archive/2010/01/05/5137364.aspx
      

  6.   

    var XMLHttp;   
    var pid;   
    var tit;   
    var $=function(id)   
    {   
       return document.getElementById(id);   
    }   
    function SubmitInfo()   
    {   
    var user=$("user").innerHTML;   
    var mail=$("mail").value;   
    var radioChk=document.getElementsByName("rank");   
    var rank;   
    var content=$("content").value;   
     for(var i=0;i<radioChk.length;i++)   
      {   
        if(radioChk[i].checked)   
        {   
         rank=radioChk[i].value;   
        }   
      }   
    var results=user+','+mail+','+rank+','+content+','+pid+','+tit;   
       ASP.wsgw_info_aspx.Num(results,callback)   
    }   
    function callback(res)   
    {   
      if(res.value==1)   
      {   
       setTimeout(ShowInfo,1000);   
      }   
    }   
        function CreateXmlHttpRequest()      
        {      
          //浏览器的判断      
          if(window.XMLHttpRequest)      
          {      
             //Mozilla浏览器      
             XMLHttp=new XMLHttpRequest();      
          }      
          //IE浏览器      
          else if(window.ActiveXObject)      
          {      
           try      
           {      
              XMLHttp=new ActiveXObject("Msxml2.XMLHttp");      
           }      
           catch (e)      
           {      
             try      
             {      
                XMLHttp=new ActiveXObject("Microsoft.XMLHttp");      
             }      
             catch(e)      
             {      
                     
             }      
           }      
          }      
        }    
      
    function ShowInfo()   
    {   
      CreateXmlHttpRequest();   
      if(XMLHttp==null)   
      {   
        return;   
      }   
      XMLHttp.open("POST","UserHandler/UserComment.ashx?ID="+pid,true);   
      XMLHttp.onreadystatechange=StateChange;   
      XMLHttp.send(null);    
    }   
    function StateChange()   
    {   
      if(XMLHttp.readyState==4)   
      {   
        if(XMLHttp.status==200)   
         {   
           var res=XMLHttp.responseText;   
           $("Comments").innerHTML=res;   
         }   
      }   
    }    
    function GetTitle()   
    {   
      pid=<%=ID %>;   
      tit='<%=Title %>';   
    }   
    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ws_hgo/archive/2010/01/05/5137364.aspx
      

  7.   


    回来时 叫JS location.reload() 
    刷新页面
      

  8.   

    最好是这样,
    首先调用AJAX将数据在数据库中删除,返回执行成功的标识后,直接调用JS在前台把那行数据删除就OK了,B/S架构核心就是尽量减少前后台的交互
      

  9.   

     <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Cache-Control" content="no-cache" />
        <meta http-equiv="Expires" content="0" />
        <meta http-equiv="imagetoolbar" content="no">
    应该由于缓存的问题把上面的代码加入<head>中
      

  10.   

    还有种方法就是在你获得数据库数据时,页面后增加一个参数:如var url="getData.aspx?rnd"+Math.Random()  好让系统页面知道是新的数据请求