HTML 5 offline and sAjaxSource question
HTML 5 offline and sAjaxSource question
Hi Allan,
I have an interesting situation
I am trying out to make the application work offline using HTML 5 mechanisms. Everything downloads and is available in the application cache of the browser. However, when I go offline/bring down the web server, I get a 502 error on the sAjaxSource file
For e.g. I have the following in the HTML
[code]
"sAjaxSource": "customer/CustomerList.txt",
"bDeferRender": true,
[/code]
When I go "offline" and try to access it, browser is trying to request in the following format - Please note the "?_=1311633738059"
http://localhost:8080/offline/customer/CustomerList.txt?_=1311633738059 and since it is not in the application cache, the rendering fails. However, when I access using the following thru browser "http://localhost:8080/offline/customer/CustomerList.txt", the data is displayed from application cache. I can see this file in the cache - but do not know why the numbers are appended at the end of the sAjaxSource value
What is causing the appending of "?_=1311633738059" - is it because of Ajax? Is there a way to prevent this when browser tries to access the file "offline"? Please advise and Thanks very much.
I have an interesting situation
I am trying out to make the application work offline using HTML 5 mechanisms. Everything downloads and is available in the application cache of the browser. However, when I go offline/bring down the web server, I get a 502 error on the sAjaxSource file
For e.g. I have the following in the HTML
[code]
"sAjaxSource": "customer/CustomerList.txt",
"bDeferRender": true,
[/code]
When I go "offline" and try to access it, browser is trying to request in the following format - Please note the "?_=1311633738059"
http://localhost:8080/offline/customer/CustomerList.txt?_=1311633738059 and since it is not in the application cache, the rendering fails. However, when I access using the following thru browser "http://localhost:8080/offline/customer/CustomerList.txt", the data is displayed from application cache. I can see this file in the cache - but do not know why the numbers are appended at the end of the sAjaxSource value
What is causing the appending of "?_=1311633738059" - is it because of Ajax? Is there a way to prevent this when browser tries to access the file "offline"? Please advise and Thanks very much.
This discussion has been closed.
Replies
When you get a chance, could you look into this? Do I need to use fnServerData or some other mechanism to retrieve the data while offline?. Is the getJSON method is appending the callback fn or something at the end of request URL? Thanks very much.
Regards
Joson
Edited the following code in jquery.datatables.js - I changed "cache": false to "cache": true and I bring down the server and thing works!!! -
[code]
this.fnServerData = function ( url, data, callback, settings ) {
settings.jqXHR = $.ajax( {
"url": url,
"data": data,
"success": callback,
"dataType": "json",
"cache": true,
"error": function (xhr, error, thrown) {
if ( error == "parsererror" ) {
alert( "DataTables warning: JSON data from server could not be parsed. "+
"This is caused by a JSON formatting error." );
}
}
} );
};
[/code]