Sys.ParameterCountException:参数计数不匹配
我在firefox
和google chrome
面临以下问题:
Sys.ParameterCountException: Parameter count mismatch.
我调用以下javascript方法onclick
:
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; }
来自firebug的链接将呈现如下:
GO
根据以下链接:
错误:Sys.ParameterCountException:参数计数不匹配。
我设置了ScriptMode = "release"
但我得到另一个错误
this._toFormattedString is not a function
IE中不存在此问题。
编辑:
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; } //------------------------------------------- }
可能值得包装您的数据:引号中的项目
data: action = 4
变
data: "action = 4"
这就是当你用不正确的参数数量调用ajax API的公共方法时会发生什么。 例如,尝试Boolean.parse("true", "what?")
。 它只需要1个参数,你传入2或你发送一个空值。
你的提交链接...../RequestList.aspx
看起来不像一个正确的地址。 所以请确保您没有传递null或错误的参数。