初学ajax 一个ajax的js 有几个为不明白 求解释
///十秒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; }}///从服务器获取数据 添加到$('#comment')function GetComment($ID,$Page){ $.ajax({ url:"Comment.aspx?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>300) { alert('内容必须在5-300字之间!'); return false; }///执行按钮StopButton('CommentSubmit', 10);//ajax $.ajax({ url:"Comment.aspx?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,1); alert(arguments[0]); $("#CommentText").val(""); //验证成功时,刷新验证码图片 $("#CommentValidateImages").attr("src","VerifyCode.aspx?s="+Math.random()); } $("#CommentValidate").val(""); } });//SetCookie("CommentUser",$CommentUser,3);}
public partial class Comment : System.Web.UI.Page{ string action = string.Empty; string id = string.Empty; string page = string.Empty; string pagehtml = string.Empty; string linkhtml = string.Empty; int Pages = 5; string commentparentid = string.Empty; string commentuser = string.Empty; string commenttext = string.Empty; string commentvalidate = string.Empty; public Comment() { // // TODO: 在此处添加构造函数逻辑 // } protected void Page_Load(object sender, EventArgs e) { action = Request.Params["action"]; id = Request.Params["id"]; page = Request.Params["page"]; commentparentid = Request.Params["commentparentid"]; commentuser = Request.Params["commentuser"]; commenttext = Request.Params["commenttext"]; commentvalidate = Request.Params["commentvalidate"]; if (action == "ajax_getcomment") { ajax_getcomment(id, Int32.Parse(page)); } else if (action == "ajax_sendcomment") { if (Session["VerifyCode"].ToString().ToLower() != commentvalidate.ToLower()) { Response.Write("ERRO5R!"); } else { DBQuery.ExecuteScalar("insert into comment(commentparentid,commentuser,commenttext,commentreply,commentip) values('" + commentparentid + "','" + commentuser + "','" + Server.HtmlEncode(commenttext) + "','','" + Request.ServerVariables["REMOTE_ADDR"] + "')"); Response.Write("评论发表成功!"); } } else { Response.Write("error!"); } } private void ajax_getcomment(string id, int page) { using (CommentBO cm = new CommentBO(id, page - 1)) { Response.Write(cm.getCommentContent()); } }}
//调用test()函数test('aa','bb');//看上去参数的个数都不匹配,但是这样调用也能成功。这就是js函数的强大function test(a){alert(a);//弹出'aa'alert(arguments[1]);//弹出'bb'};