Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sys.ParameterCountException: Parameter count mismatch

I face the following problem in firefox and google chrome :

Sys.ParameterCountException: Parameter count mismatch. 

I call the following javascript method 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 :

<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.

I set the ScriptMode = "release"

but i get another error

this._toFormattedString is not a function

This problem isn't exist in 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;
        }

    //-------------------------------------------
    }
like image 379
Anyname Donotcare Avatar asked Jun 14 '12 11:06

Anyname Donotcare


3 Answers

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.

also your submit link ...../RequestList.aspx does not look like a proper address. so make sure you are not passing null or wrong parameters.

like image 122
Vartan Arabyan Avatar answered Oct 29 '22 02:10

Vartan Arabyan


Possibly worth wrapping your data: item in quotes

data: action = 4

becomes

data: "action = 4"
like image 43
Luke Baughan Avatar answered Oct 29 '22 03:10

Luke Baughan


setting debug="false" in de web.config seemed to remove the error

like image 28
symbiont Avatar answered Oct 29 '22 02:10

symbiont