ASP Ajax Source RETURNS WRONG JSON FORMAT... PLEASE
ASP Ajax Source RETURNS WRONG JSON FORMAT... PLEASE
Here is my init code for dataTable:
[code]
$(document).ready(function() {$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "../AspFiles/FrontDeskAjax.asp"
} );
} );
[/code]
When I execute the ASP Ajax source (FrontDeskAjax.asp) alone and test it on JSONint it says my format is valid. Even when I copy just the Json and parse it as a txt file, it works perfectly.
Here is my ASP (Javascript) file code:
[code]
<%var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=../../../db/PDataBase2.mdb";
Session("ConnectObj")= Server.CreateObject("ADODB.Connection");
Session("ConnectObj").Open (myConnect);
var RS2 = Server.CreateObject("ADODB.recordset");
var Ssql="SELECT * FROM ResidentByName";
RS2.Open(Ssql, Session("ConnectObj"),adOpenForwardOnly,adLockReadOnly,adCmdText);
var iTotalDisplayRecords=0;
var iTotalRecords=0;
var x=0;
if(!RS2.BOF) RS2.MoveFirst();
while(!RS2.EOF)
{
iTotalDisplayRecords=iTotalDisplayRecords+1;
iTotalRecords=iTotalRecords+1;
RS2.MoveNext();
}
Response.Write('{"sEcho":'+ sEcho+', "iTotalRecords": "'+iTotalRecords+'","iTotalDisplayRecords":"'+iTotalDisplayRecords+'", "aaData": [');
var i=0;
if(RS2.EOF){RS2.MoveFirst();
while(!RS2.EOF){
Response.Write('["');
while(x <= RS2.Fields.Count-1)
{ if(x==RS2.Fields.Count-1) Response.Write(RS2.Fields(x).value)+ Response.Write('"');
else Response.Write(RS2.Fields(x).value)+ Response.Write('","');
x++;
}
x=0;
RS2.MoveNext();
i++;
if(i==iTotalRecords) Response.Write(']');
else Response.Write('],');
}
}
Response.Write ('] }');
%>
[/code]
It obviously not my Json format, the problem is certainly coming from my the way my asp file is parsing the json...So what I my doing wrong?
Please help! Been working on it all day and night.
[code]
$(document).ready(function() {$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "../AspFiles/FrontDeskAjax.asp"
} );
} );
[/code]
When I execute the ASP Ajax source (FrontDeskAjax.asp) alone and test it on JSONint it says my format is valid. Even when I copy just the Json and parse it as a txt file, it works perfectly.
Here is my ASP (Javascript) file code:
[code]
<%var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=../../../db/PDataBase2.mdb";
Session("ConnectObj")= Server.CreateObject("ADODB.Connection");
Session("ConnectObj").Open (myConnect);
var RS2 = Server.CreateObject("ADODB.recordset");
var Ssql="SELECT * FROM ResidentByName";
RS2.Open(Ssql, Session("ConnectObj"),adOpenForwardOnly,adLockReadOnly,adCmdText);
var iTotalDisplayRecords=0;
var iTotalRecords=0;
var x=0;
if(!RS2.BOF) RS2.MoveFirst();
while(!RS2.EOF)
{
iTotalDisplayRecords=iTotalDisplayRecords+1;
iTotalRecords=iTotalRecords+1;
RS2.MoveNext();
}
Response.Write('{"sEcho":'+ sEcho+', "iTotalRecords": "'+iTotalRecords+'","iTotalDisplayRecords":"'+iTotalDisplayRecords+'", "aaData": [');
var i=0;
if(RS2.EOF){RS2.MoveFirst();
while(!RS2.EOF){
Response.Write('["');
while(x <= RS2.Fields.Count-1)
{ if(x==RS2.Fields.Count-1) Response.Write(RS2.Fields(x).value)+ Response.Write('"');
else Response.Write(RS2.Fields(x).value)+ Response.Write('","');
x++;
}
x=0;
RS2.MoveNext();
i++;
if(i==iTotalRecords) Response.Write(']');
else Response.Write('],');
}
}
Response.Write ('] }');
%>
[/code]
It obviously not my Json format, the problem is certainly coming from my the way my asp file is parsing the json...So what I my doing wrong?
Please help! Been working on it all day and night.
This discussion has been closed.