| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1328 人关注过本帖
标题:请教 关于ASP提交数据后返回上一页并刷新 出现死循环问题
只看楼主 加入收藏
enjoy535
Rank: 1
等 级:新手上路
帖 子:114
专家分:3
注 册:2007-1-16
结帖率:40%
收藏
已结贴  问题点数:20 回复次数:3 
请教 关于ASP提交数据后返回上一页并刷新 出现死循环问题
RT...
我想实现在提交数据后页面自动返回上一页并刷新的过程,但是却发现在返回的时候页面不断地提交数据,进入了一个死循环,请高手帮我看看问题出在哪里,谢谢!

A页面提交表格代码:
<form name="form1" method="post" action="?type=addnew">
      <textarea name="txt_dayday" cols="50" class="list_tab_bian" id="txt_dayday"></textarea>
    <input name="Submit" type="submit" class="tab_bian" value="提交">
</form>

A页面添加数据代码,这段是在A页面前端的
<%
'新增记录================================
sub alarm_yes(word)    '确认框,点击确定后返回前一页并刷新
dim words
    words=word
    response.Write "<script language='javascript'>"
    response.Write "alert('"&words&"');"
    response.Write "history.back(-1);"
    response.Write "location.reload();"
    response.Write "</script>"
    response.End()
end sub

if request("type")="addnew" then
        conn.execute("insert into dayday (day_content) values ('"&trim(request.Form("txt_dayday"))&"')")
    if not err then
        call alarm_yes("添加成功!")
    else
        call alarm_no("添加失败!")
    end if
end if
%>

现在的问题就是当我在A页面提交数据后,A页面会提交记录到数据库里面,并且会弹出确认框,但我在点击确认框的“确定”按钮后,页面又再一次返回到之前的提交页面http://127.0.0.1/a.asp?type=addnew,并且会再弹出一个“重新提交数据”的“重试”框,如果点了“重试”,页面又会再次提交记录,再“确定”...不断进入一个死循环

请高人指点一下,到底是哪个地方出错了,为什么返回历史网址时还会自动带上提交的数据?能不能去掉?
我history.back(-1);、history.back(-2);、history.back();都测试过了,都不行
搜索更多相关主题的帖子: 记录 action method class input 
2011-04-11 22:05
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
收藏
得分:10 
sub alarm_yes(word)    '确认框,点击确定后返回前一页并刷新
dim words
    words=word
    response.Write "<script language='javascript'>"
    response.Write "alert('"&words&"');"
    response.Write "window.location.href='a.asp';"
    response.Write "</script>"
    response.End()
end sub


QQ:63572063
2011-04-11 23:17
zznice
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:32
专家分:102
注 册:2011-2-7
收藏
得分:10 
<form name="form1" method="post" action="?type=addnew">
改成
<form name="form1" method="post" action="a.asp">

response.Write "history.back(-1);"
改成
response.redirect "a.asp"

[ 本帖最后由 zznice 于 2011-4-11 23:35 编辑 ]
2011-04-11 23:31
enjoy535
Rank: 1
等 级:新手上路
帖 子:114
专家分:3
注 册:2007-1-16
收藏
得分:0 
谢谢楼上两位的帮助

其实我现在就是用的location.href方法:
sub alarm2(word,path)    '确定型弹出框,点击后跳转至目标页
dim words,where
    words=word
    where=path
    response.Write "<script language='javascript'>"
    response.Write "alert('"&words&"');"
    response.Write "location.href='"&where&"';"
    response.Write "</script>"
    response.End()
end sub

但我想编一个sub,可以随时调用,而且不用传递跳转url过去。
因为有时候会在分页列表的中间某页修改或者删除记录,那时候如果再传递一个url过去有点麻烦,所以我就想试试能不能在提交编辑后直接返回到历史url,然后再自动刷新,并且直接做成一个sub,方便随时调用,所以才试着编了上面一个页面...

2011-04-12 21:37
快速回复:请教 关于ASP提交数据后返回上一页并刷新 出现死循环问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011869 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved