求高手帮忙,在线等,AJAX提交问题
时间:2010-10-14
来源:互联网
问题是在根目录下有效,在子目录下提交不成功
提交部分
HTML code
JS部分
JScript code
ASP部分
HTML code
提交部分
HTML code
<!--评论输入框开始--> <div style="padding:4px"></div> <div class="post"> <div style="padding:4px"></div> <label> 昵 称(*)</label> <input type="text" id="CommentUser" onFocus="this.className='focus postvalidate'" onBlur="this.className='blur postvalidate'" class="blur postuser" value="匿名网友" /> <div style="padding:2px"></div> <label> 验证码(*)</label> <input type="text" class="blur postvalidate" id="CommentValidate" onFocus="this.className='focus postvalidate'" onBlur="this.className='blur postvalidate'" maxlength="4" /> <img id='CommentValidateImages' style='cursor:pointer;height:20px;width:80px;' src="about:blank" onerror="this.onerror=null;this.src='/co/coadvblue/Code.asp?s='+Math.random();" alt="验证码" title="看不清楚?换一张" onClick="src='/co/coadvblue/Code.asp?s='+Math.random()" /> <div style="padding:2px"></div> <label> 内 容(*)</label> <textarea id="CommentText" onFocus="this.className='focus posttext'" onBlur="this.className='blur posttext'" class="blur posttext"></textarea> <div style="padding:2px"></div> <span style="padding-left:60px;"> </span><input type='button' class="postsubmit" id="CommentSubmit" value='提交' onClick="SendComment(1)" /> <div style="padding:2px"></div> </div> <!--评论输入框结束-->
JS部分
JScript code
function StopButton(){ document.getElementById(arguments[0]).disabled=true; document.getElementById(arguments[0]).value="提交("+arguments[1]+")"; if(--arguments[1]>0){ window.setTimeout("StopButton('"+arguments[0]+"',"+arguments[1]+")",1000); } if(arguments[1]<=0){ document.getElementById(arguments[0]).value='提交'; document.getElementById(arguments[0]).disabled=false; } } function GetComment($ID,$Page){ $.ajax({ url:"Comment.asp?action=ajax_getcomment&id="+$ID+"&page="+$Page+"&time"+new Date().toString(), type:'GET', success:function(){ $('#comment').html(arguments[0]); } }); } function SendComment(){ var $CommentParentID =arguments[0]; var $CommentUser =$('#CommentUser').val(); var $CommentText =$('#CommentText').val(); var $CommentValidate =$('#CommentValidate').val(); if ($.trim($CommentUser)=='') { alert('请您填写昵称!'); $('#CommentUser').focus(); return false; } if ($.trim($CommentValidate)=='') { alert('请您填写验证码!'); $('#CommentValidate').focus(); return false; } if ($.trim($CommentText)=='') { alert('请您填写回复内容!'); $('#CommentText').focus(); return false; } if ($CommentText.length<5||$CommentText.length>200) { alert('内容必须在5-200字之间!'); return false; } StopButton('CommentSubmit',10); $.ajax({ url:"Comment.asp?action=ajax_sendcomment&commentparentid="+$CommentParentID+"&commentuser="+escape($CommentUser)+"&commenttext="+escape($CommentText)+"&commentvalidate="+escape($CommentValidate)+"&time="+new Date().toString(), type:'GET', success:function(){ if (arguments[0]=='ERROR') { alert('验证码出错!'); }else{ GetComment($CommentParentID,0); alert(arguments[0]); $("#CommentText").val(""); //验证成功时,刷新验证码图片 $("#CommentValidateImages").attr("src","/co/coadvblue/Code.asp?s="+Math.random()); } $("#CommentValidate").val(""); } }); //SetCookie("CommentUser",$CommentUser,3); }
ASP部分
HTML code
Function ajax_sendcomment() Dim commentparentid, commentuser, commenttext, commentvalidate OpenConn(DbPath) commentparentid = Request.QueryString("commentparentid") commentuser = unescape(Request.QueryString("commentuser")) commenttext = unescape(Request.QueryString("commenttext")) commentvalidate = unescape(Request.QueryString("commentvalidate")) If CStr(session("GetCode"))<>commentvalidate Then Echo ("ERROR") Response.End() Else Sql = "insert into comment(commentparentid,commentuser,commenttext,commentreply,commentip) values('"&commentparentid&"','"&commentuser&"','"&Server.HTMLEncode(commenttext)&"','','"&GetIP()&"')" Set Rs = Conn.Execute(Sql) CloseRs() CloseConn() Echo ("评论发表成功.") End If End Function
作者: z_e_h 发布时间: 2010-10-14
CSS code
路径处用绝对路径看看
作者: IBM_hoojo 发布时间: 2010-10-14
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28