locked
pass json data to aspx webmethod page error: “System.Collections.Generic.IDictionary`2 is not supported for deserialization of an array” RRS feed

  • Question

  • User871652276 posted

    I Want Pass json Object to WebMethod in aspx page

    here's my jquery and WebMethod

    $("#button-login").bind({
    click: accountRegister
    });

    function accountRegister(e) {


    var dataObj = $("#login input[type]").serializeArray();
    var obj = JSON.stringify(dataObj);

    $.ajax({
    type: "POST",
    url: "Checkout.aspx/login",
    data: obj,
    contentType: "application/json; charset=UTF-8",
    dataType: "json",
    beforSend: function () {
    $(this).attr("disabled", "true");
    $(this).after(waitObj);
    },

    success: function (msg) {
    // Replace the div's content with the page method's return.
    alert("success");
    $("#checkout").slideUp("slow");
    $("#payment-address").slideDown("slow");
    },
    error: function (msg) {
    //alert(msg);
    },
    complete: function (jqxhr,status) {
    alert("Type:" + $.type(jqxhr) + "\n Respons text: " + jqxhr.responseText + "\n status: " + status);

    $(this).attr("disabled", "false");
    $(".wait").remove();

    },
    });
    }

    namespace Ahooratech
    {

    public partial class Checkout : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    [WebMethod]
    public static void login(string obj)
    {

    return "{data:data}";

    }

    I Get This Error:

    {"Message":"Type \u0027System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]\u0027 is not supported for deserialization of an array.",

    "StackTrace":"   at System.Web.Script.Serialization.ObjectConverter.ConvertListToObject(IList list, Type type, JavaScriptSerializer serializer, Boolean throwOnError, IList\u0026 convertedList)\r\n   at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject)\r\n   at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n   at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n   at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
    Monday, May 20, 2013 7:51 AM

All replies