Sys.ParameterCountException:参数计数不匹配

问题描述 投票:12回答:3

我在firefoxgoogle chrome中遇到以下问题:

Sys.ParameterCountException: Parameter count mismatch. 

我调用以下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>

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>

根据以下链接:

Error: Sys.ParameterCountException: Parameter count mismatch.

我设置了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;
        }

    //-------------------------------------------
    }
javascript jquery asp.net ajax updatepanel
3个回答
6
投票

可能值得包装数据:用引号引起来的项目

data: action = 4

成为

data: "action = 4"

6
投票

这就是使用错误数目的参数调用ajax API的公共方法时发生的情况。例如,尝试Boolean.parse("true", "what?")。它仅需要1个参数,您传入2个参数或发送空值。

而且您的提交链接...../RequestList.aspx看起来也不正确。因此请确保您没有传递null或错误的参数。


0
投票

de web.config中的设置debug =“ false”似乎删除了该错误

© www.soinside.com 2019 - 2024. All rights reserved.