AJAX JSON WebMethods return string not binding

AJAX JSON WebMethods return string not binding

john.sheehan@careerbuilder.comjohn.sheehan@careerbuilder.com Posts: 1Questions: 0Answers: 0

Having issues using webmethods returning serialized json data. The data returns and is well formed.
The datatable fills up with blanks. Is there a standard way of returning the data from .NET (VB or C#)

example:
Return JsonConvert.SerializeObject(vObject)

$.ajax({

Replies

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    This doc describes the data sources and types supported by Datatables:
    https://datatables.net/manual/data/

    If you are getting blank rows then I would guess the data structure you are supplying to datatables doesn't match the structure you have configured. Maybe you can provide a link to the page with the issue. If not then start with collecting debugger information and posting the link provided.

    Do you receive an error message?

    Kevin

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    There are two issues that those that are new to WebMethods run in to.

    1. Even though you are using Newton soft to serialize your data, Microsoft .net will serialize it again before sending it to the client. At the client, its only being deserialized once (by ajax) to that table still gets just a string.
    2. No matter what you do, Microsoft puts your return in an object call "d"

    So you have to account for both in your response.

    Here are some working samples https://github.com/bindrid/DataTablesServerSide

This discussion has been closed.