Javascript Sys.ParameterCountException:参数计数不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11032413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sys.ParameterCountException: Parameter count mismatch
提问by Anyname Donotcare
I face the following problem in firefox
and google chrome
:
我在firefox
和 中面临以下问题google chrome
:
Sys.ParameterCountException: Parameter count mismatch.
I call the following javascript method onclick
:
我调用以下 javascript 方法onclick
:
<script type="text/javascript">
var confirmSubmited = false;
function SubmitWithLog(par_name, par_address, frm) {
jQuery.ajax({
url: "/LogAction.ashx?par_name=" + par_name + "&par_address=" + par_address,
type: "GET",
timeout: 3000,
async: true, // you can try and async:false - maybe is better for you
data: action = 4, // here you send the log informations
cache: false,
success: function(html) {
jQuery(frm).submit();
},
error: function(responseText, textStatus, XMLHttpRequest) {
jQuery(frm).submit();
}
});
return false;
}
</script>
The link from firebug will render like this :
来自 firebug 的链接将呈现如下:
<a href="#" onclick="SubmitWithLog('%d8%b7%d9%84%d8%a8+%d8%a5%d9%84%d8%aa%d9%85%d8%a7%d8%b3+??%d9%84%d9%84%d9%85%d9%88%d8%a7%d8%b1%d8%af+%d8%a7%d9%84%d8%a8%d8%b4%d8%b1%d9%8a%d??8%a9','...../RequestList.aspx','#ctl43');return false;">GO </a>
according to the following link :
根据以下链接:
Error: Sys.ParameterCountException: Parameter count mismatch.
错误:Sys.ParameterCountException:参数计数不匹配。
I set the ScriptMode = "release"
我设置了 ScriptMode = "release"
but i get another error
但我收到另一个错误
this._toFormattedString is not a function
This problem isn't exist in IE.
这个问题在 IE 中不存在。
EDIT :
编辑 :
public class LogAction : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest(HttpContext con)
{
// log here what you wish
string[] statistics = TrackUser();
string a = HttpUtility.UrlDecode(con.Request.Params["Par_name"].ToString());
string b = con.Request.Params["Par_address"].ToString();
TraceActivity(a, b, statistics[0], statistics[1], statistics[2]);
// end up with no content
con.Response.TrySkipIisCustomErrors = true;
con.Response.Status = "204 No Content";
con.Response.StatusCode = 204;
}
//-------------------------------------------
}
采纳答案by bUKaneer
Possibly worth wrapping your data: item in quotes
可能值得包装您的数据:引号中的项目
data: action = 4
becomes
变成
data: "action = 4"
回答by Vartan Arabyan
Thats what happens when you call a public method of an ajax API with the incorrect number of parameters. For example, try Boolean.parse("true", "what?")
. It only takes 1 parameter, you passed in 2 or your sending a null value.
这就是当您使用不正确数量的参数调用 ajax API 的公共方法时会发生的情况。例如,尝试Boolean.parse("true", "what?")
。它只需要 1 个参数,您传入 2 或发送一个空值。
also your submit link ...../RequestList.aspx
does not look like a proper address.
so make sure you are not passing null or wrong parameters.
您的提交链接...../RequestList.aspx
看起来也不像是一个正确的地址。所以请确保您没有传递 null 或错误的参数。
回答by symbiont
setting debug="false" in de web.config seemed to remove the error
在 de web.config 中设置 debug="false" 似乎消除了错误