Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82042

DataTable Ajax with Remote Data Source & JSON

$
0
0
Guys

Im trying to load data from a Remote Data Source and it keeps failing. Below is my Web Method developed in VB.NET.
 <WebMethod()> _
    Public Shared Function Users() As String

        Dim TheFitFemContext As EntitiesContext = New EntitiesContext 

        Dim Results = (From U In EntitiesContext.Users
        
        Select New With {U.UserID})

        Dim serializer As New JavaScriptSerializer()
        
        Dim json As String = serializer.Serialize(Results)


        Return json

    End Function

Here's my jQuery Code

                $('#example').dataTable({
                    "bProcessing": true,
                    "bServerSide": true,
                    "sAjaxSource": ApplicationPath + "/Administrator/Users.aspx/Users",
                    "fnServerData": function (sSource, aoData, fnCallback) {
                        $.ajax({
                            "dataType": 'json',
                            "contentType": "application/json; charset=utf-8",
                            "type": "POST",
                            "url": sSource,
                            "data": '{}',
                            "success": function (data) 
                            {
                                fnCallback(data.d);
                            }
                        });
                    } 
                })                    

When I run the code and I get the following as my Results

{"d":"[{\"UserID\":\"451\",\"Name\":\"John Doe\",\"Address\":\"123 Test Ave, DK, 11234\",\"Date_Created\":\"\\/Date(1327039200000)\\/\",\"Status\":\"Not Active\",\"IsLockedOut\":\"Not Locked Out\",\"Type\":\"Trial\",\"Email\":\"UserName@DomainName.com\",\"ResetPassword\":\"*\"}]"}
and my table does not populate instead I get this error


Error: Unable to get value of the property 'length': object is null or undefined

Viewing all articles
Browse latest Browse all 82042

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>