Link to home
Start Free TrialLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

Building JSON/JQuery Results Display

I am in the process of building a results display for races that I time.  I think I have a sense of how to collect the data, thanks to Big Monty on a previous post, but I am not sure I truly understand how to set the "first page" up.  Could someone please look at this link and let me know what is not up to speed?  I want to filter the table by any/all of the values first_name, last_name, gender, and age.  I want the table to sort based on column click, and I want it to show up to 10 results (although I may change that later).

I appreciate your help and patience as I try to learn this technology.
Avatar of HainKurt
HainKurt
Flag of Canada image

i dont see any submit button and page does not do anything...
Avatar of Bob Schneider

ASKER

I don't think there needs to be a submit button or a form with jquery.  The changes would be made onload and when the inputs change.  But I know the page does nothing.  I am looking for some assistance with the source to ensure that it is set up corectly while I work on the data page.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have begun implementing the suggestions above.  Can you folks take a look and see if anything jumps out at you as redundant, incorrect, or otherwise "bad."

One thing that I am struggle with is how to "present" the data on the url that is feeding the data to this page.  Here is what I had on a similar page:
{
  "data": [
        <%For i = 0 To UBound(Results, 2)%>
            [
            <%For j = 0 To 9%>
                "<%=Results(j, i)%>"
                <%If j < 3 Then %>
                    <%Response.Write ","       '-- don't output a comma on the last element%>
                  <%End If%>
                <%Next%>
            ]

            <%If i < UBound(Results, 2) Then %>
                <%Response.Write ","         '-- don't output a comma on the last section%>
            <%End If%>
        <%Next%>
]
}

Open in new window

I assume that using a data table makes this snippet obsolete but how do I get the data into the data table?  Note that I do not have <tbody></tbody> in my table.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have simplified this dramatically and adopted the use of datatables.  Can someone look at this page and let me know if something is amiss...obviously it is.

Here is my code on the server-side page for processing the data for the table:
Response.Buffer = True		'Turn buffering on
Response.Expires = -1		'Page expires immediately
				
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLNCLI11;Server=12.34.56.78;Database=DB;Uid=Uid;Pwd=pwd;"

Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT TOP " & iLength & " PR.Bib, P.FirstName, P.LastName, P.Gender, PR.Age, IR.ChipTime, IR.FnlTime, IR.ChipStart, P.City, P.St "
sql = sql & "FROM RaceData AS R INNER JOIN PartRace AS PR ON R.RaceID = PR.RaceID INNER JOIN Participant AS P ON PR.ParticipantID = P.ParticipantID "
sql = sql & "INNER JOIN (SELECT DISTINCT RaceID, ParticipantID, ChipTime, FnlTime, ChipStart, FnlScnds FROM IndResults WHERE FnlTime IS NOT NULL "
sql = sql & "AND FnlTime > '00:00:00.000') AS IR ON R.RaceID = IR.RaceID AND P.ParticipantID = IR.ParticipantID WHERE R.RaceID = 1079"
rs.Open sql, conn, 1, 2
If rs.RecordCount > 0 Then
    Results = rs.GetRows()
Else
    ReDim Results(9, 0)
End If
rs.Close
Set rs = Nothing

For i = 0 To UBound(Results, 2)
    Results(0, i) = i + 1
Next

conn.Close
Set conn = Nothing
%>

{
  "data": [
        <%For i = 0 To UBound(Results, 2)%>
            [
            <%For j = 0 To 9%>
                "<%=Results(j, i)%>"
                <%If j < 9 Then %>
                    <%Response.Write ","       '-- don't output a comma on the last element%>
                  <%End If%>
                <%Next%>
            ]

            <%If i < UBound(Results, 2) Then %>
                <%Response.Write ","         '-- don't output a comma on the last section%>
            <%End If%>
        <%Next%>
]
}

Open in new window


Can anyone give me any insight with this page?
If anyone is listening, the page is now working fine but giving no data even though the sql pulls data when used as a view in SSMS.
I am seeing data unless I don't know what I am looking for - which is likely
No I am working on it so it is ebbing and flowing...