Problems while using datatables locally

Problems while using datatables locally

ishanjainishanjain Posts: 6Questions: 0Answers: 0
edited January 2012 in General
I am trying to run a little setup where my HTML page will pull data from an XML file and display with all searching and sorting features through datatables. But i am planning to run this html page locally on the computer. Please note this point as my problem belongs here.

Firstly, i wrote some javascript to pull out xml data and create tables from it...

[code]
var x = [];
xmlhttp=new XMLHttpRequest();

xmlhttp.open("GET","author.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

data=xmlDoc.getElementsByTagName("paper");
for(i=0 , l = data.length; i < l ; i++)
x.push(data[i]);

sorting(x);


for (i=0;i

Replies

  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    > So i figured out that the page in unable to locate jquery.js and datatable.js which is inside some folder structure, i just dont know why.

    I'd suggest trying your test page in Chrome and have a look at the "Inspector" there. The Webkit dev tools will show on the console any files which are getting a 404 error - which is exceptionally useful, particularly for this kind of thing :-)

    Allan
  • ishanjainishanjain Posts: 6Questions: 0Answers: 0
    Chrome console says, "failed to load resource", for all 4 files, 3 script and 1 demo_table.css
    I am uploading the files here. Please check them after downloading locally and dont use any web server or anything.

    http://www.mediafire.com/?wqba0ras7tl68e5

    Now in this i have prepared 2 folders.

    1) Is the script which i wrote just to parse data from excel and show it in tabular form. Dont bother about the inefficient code i wrote, i included it just to show that array 'x' contains the proper data. Please note that i observed it later but 'x' is a 1D array. Can you convert it to 2D array? Also, dont try this one in chrome as chrome doesnt allow inclusion of local files.

    2) These are the datatables files which i copied from the sub folder to the folder where the page is located and modified the script tag accordingly. This made a lot of difference but still it is not complete. I think it is not properly loading the files from subfolders
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    There are a number of issues with the "script.js" file (I've looked at the "data tables with DOM" example only). You've mixed window.onload and $(document).ready - which you can get away with, but usually isn't a very good idea. You typically want just one.

    Also your $(document).ready function is inside the import_xml function - I'm not sure if this is intentional or not, and you are appending your TR rows to the TABLE, not the TBODY as required by DataTables ( http://datatables.net/usage ).

    Here is a modification of that file that works:

    [code]

    function main()
    {
    import_xml();
    }

    function sorting(x)
    {
    for(i=0, l= x.length;i
  • ishanjainishanjain Posts: 6Questions: 0Answers: 0
    Thanks a million allan... I just cant tell you what a load this problem has been to me.. you solved it in minutes... Thanx a lot man...
    Just a few questions and i wont be bugging you anymore :)

    1) I want to open some pdf file upon clicking a row, unique for each row and also i want some effects for hover on rows. Can i do this all in my javascript code while i create the rows ??

    2) As you might have noticed, there was no styling in the table probably due to the path issue as it is not being able to get the files from within the directory structure. What can i do to add different styles to my table and also i want to change some font styles.
This discussion has been closed.