web-dev-qa-db-ja.com

Sys.ParameterCountException:パラメーター数の不一致

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>

次のリンクによると:

エラー: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;
        }

    //-------------------------------------------
    }
13

データをラップする価値があるかもしれません:引用符で囲まれたアイテム

data: action = 4

になります

data: "action = 4"
6
bUKaneer

これは、誤った数のパラメーターを使用してajaxAPIのパブリックメソッドを呼び出すと発生します。たとえば、Boolean.parse("true", "what?")を試してください。パラメータは1つだけで、2を渡すか、null値を送信します。

また、送信リンク...../RequestList.aspxは適切なアドレスのようには見えません。したがって、nullまたは間違ったパラメータを渡していないことを確認してください。

6
Vartan Arabyan

deweb.configでdebug = "false"を設定すると、エラーが削除されたようです

0
symbiont