下面的arguments[0]什么意思? 是服务器段的东西啊 是服务器段的东西啊 是服务器段的东西啊$.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("");
}
});
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("");
}
});
但它的类型是object. 可通过下标访问其中元素,也可通过length获得个数 arguments 与 js 函数定义的 参数无关, 无论你是否定义参数,都可传递任意个参数。 arguments[0] 就是 获取第一个参数
if (arguments[0]=='ERROR')
{
alert('验证码出错!');
}
函数的规范写法是
success:function(responseText){
if (responseText=='ERROR')
{
alert('验证码出错!');
}
}因为 success 后的函数 在响应成功返回后 会被调用 并传递一个参数(responseText) 也就是返回的响应文本 ,所以你 success 后的函数 不定义参数 它还是会传递 这个时候想要访问传递的参数 就需要用 arguments[0]
http://topic.csdn.net/u/20091028/09/daf364c6-65f5-4efd-9934-b1656cdfa078.html
success:function(d){
if (d=='ERROR')
{
alert('验证码出错!');
}
}
这个函数的形式 你能理解么?
arguments[0]就是传出来的第一个参数
success:function(d){
if (d=='ERROR')
{
alert('验证码出错!');
}
}
这段函数的效果是 在 ajax 请求服务器成功之后 jQ 框架会回调 success 后的函数 ,会把xmlHttpRequest.responseText 当做参数传递假设 success 后的函数名为 method, jQ 回调的格式 为 method(xmlHttpRequest.responseText);这个时候 d 就等于 xmlHttpRequest.responseText 而
success:function(){
if (arguments[0]=='ERROR')
{
alert('验证码出错!');
}
}
同样也是 在ajax 请求服务器成功之后 被回调jQ框架 还是会传递 参数 依然是 xmlHttpRequest.responseText 这个时候 函数定义是无参的,但js 函数的特性是 调用函数时你可以为函数传递任意个参数即便 你定义成无参的函数, 所以 xmlHttpRequest.responseText 还是被传递到函数内部这个时候你想获得 这个 xmlHttpRequest.responseText 就需要 使用 arguments 这个 js 函数特有的东东了相对应的 arguments[0] 就是 xmlHttpRequest.responseText 了