JSON data from server failed to load or be parsed with aspx page [RESOLVED]
JSON data from server failed to load or be parsed with aspx page [RESOLVED]
AlexDtTables
Posts: 6Questions: 0Answers: 0
Hi,
First of all, congratulation for the work!
I tried to use datatables with aspx page (C#). Unfortunately, the same error occured each time I tried to call my page which create my json outpout.
Please find below my call.aspx HTML page:
[code]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="call.aspx.cs" Inherits="call" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "test.aspx"
} );
} );
Rendering engine
Browser
Platform(s)
Engine version
Rendering engine
Browser
Platform(s)
Engine version
[/code]
And the aspx C# page (test.aspx) :
[code]
public partial class test : Page
{
protected void Page_Load(object sender, EventArgs e)
{
string jsonstring = "{ \"aaData\": [[\"Trident\",\"Internet Explorer 4.0\",\"Win 95+\",\"4\",\"X\"],[\"Trident\",\"Internet Explorer 5.0\",\"Win 95+\",\"5\",\"C\"],[\"Other browsers\",\"All others\",\"-\",\"-\",\"U\"]] }";
Response.Write(jsonstring);
}
}
[/code]
If I used arrays.txt file instead of my aspx C# page, the table is displayed but if I use my specific page which returns json string output I have the error : DataTables warning: JSON data from server failed to load or be parsed. This is most likely to be caused by a JSON formatting error.
If I call my page "test.apsx" in my browser, the output is like this:
[code]
{ "aaData": [["Trident","Internet Explorer 4.0","Win 95+","4","X"],["Trident","Internet Explorer 5.0","Win 95+","5","C"],["Other browsers","All others","-","-","U"]] }
[/code]
And this output is a valid JSON (validated by http://jsonlint.com/).
For information, I'm using the last version of datatable (1.8.2 with jquery 1.6.3).
Could you please help me to find why this error occured?
Thanks
First of all, congratulation for the work!
I tried to use datatables with aspx page (C#). Unfortunately, the same error occured each time I tried to call my page which create my json outpout.
Please find below my call.aspx HTML page:
[code]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="call.aspx.cs" Inherits="call" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "test.aspx"
} );
} );
Rendering engine
Browser
Platform(s)
Engine version
Rendering engine
Browser
Platform(s)
Engine version
[/code]
And the aspx C# page (test.aspx) :
[code]
public partial class test : Page
{
protected void Page_Load(object sender, EventArgs e)
{
string jsonstring = "{ \"aaData\": [[\"Trident\",\"Internet Explorer 4.0\",\"Win 95+\",\"4\",\"X\"],[\"Trident\",\"Internet Explorer 5.0\",\"Win 95+\",\"5\",\"C\"],[\"Other browsers\",\"All others\",\"-\",\"-\",\"U\"]] }";
Response.Write(jsonstring);
}
}
[/code]
If I used arrays.txt file instead of my aspx C# page, the table is displayed but if I use my specific page which returns json string output I have the error : DataTables warning: JSON data from server failed to load or be parsed. This is most likely to be caused by a JSON formatting error.
If I call my page "test.apsx" in my browser, the output is like this:
[code]
{ "aaData": [["Trident","Internet Explorer 4.0","Win 95+","4","X"],["Trident","Internet Explorer 5.0","Win 95+","5","C"],["Other browsers","All others","-","-","U"]] }
[/code]
And this output is a valid JSON (validated by http://jsonlint.com/).
For information, I'm using the last version of datatable (1.8.2 with jquery 1.6.3).
Could you please help me to find why this error occured?
Thanks
This discussion has been closed.
Replies
Having said that, I wouldn't expect that to be the error you get when the reply comes back. What does Firebug show?
Allan
Thanks for your answer.
In fact, HTML code has been added by the ASP page automatically with Response.Write(...)
I have added Response.End(); after Write() and all works fine now!
Thanks for your help!
Regards.