Invalid JSON primitive: data.

Invalid JSON primitive: data.

info@invisiblefarm.itinfo@invisiblefarm.it Posts: 11Questions: 4Answers: 0

Debugger code (debug.datatables.net):
no relevant error by Javascript snippet
Error messages shown:
by Dev Console, I have this error

{
  "Message": "Invalid JSON primitive: data.",
  "StackTrace": "   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\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.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)",
  "ExceptionType": "System.ArgumentException"
}

Description of problem:
The code is C# and datas are retrieve by WebMethod (System.Web.Services.WebService, ASMX extension): I know it's an old technology, but I can't update.

I've got a Datatable 1.10.10 with Editor (default style): the loading phase is great and show the data. The edit phase gave me the error upside: by Network tab, Payload is encoded (es: %5D, %5B) and I can't edit the data.

Can you help me to resolve the problem?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765

    I'm guessing that means the server is unable. to read the data as sent by the Editor and that you will need to convert it to JSON formatted data. See the last example in the ajax.data option to see how to do this.

    Kevin

  • info@invisiblefarm.itinfo@invisiblefarm.it Posts: 11Questions: 4Answers: 0

    Hi @kthorngren ,
    in my opinion, I don't need parameters passed by ajax.data: I follow .NET Examples (Compound database primary key) and this example don't use data

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765
    Answer ✓

    I'm not familiar with .NET but maybe this SO thread will help.

    Kevin

  • info@invisiblefarm.itinfo@invisiblefarm.it Posts: 11Questions: 4Answers: 0

    Thanks Kevin, by your hint I do a better debug and I understand that DtEditor pass params to WebMethod in wrong JSON format. I resolve with: JSON.stringify(params)

Sign In or Register to comment.