f is undefined

f is undefined

Charly232Charly232 Posts: 2Questions: 0Answers: 0

Hello,

I have read some post about this but i cant resolved my issue...

Datatable says "Loading" but nothing appears. I have tried with .json file, .txt and php array but nothing.

Do you have a solution ?

Link to : Datatable
Txt file : File
And php file : Php

Thank's in advance for you're help and sorry for my english :smile:

Replies

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    It looks to me like your data is not coming back in a spot that DataTables is expecting. Unless you are using the dataSrc option, {data:{your table data goes here}}.
    Also, assuming that file is your data, the data structure in it does match your definition.


    {data:[{Type:"", PrenomPsn, NbVoix:"", RapportExprime: "",LibSubCom:"", CodDpt:""}, {Type:"", PrenomPsn, NbVoix:"", RapportExprime: "",LibSubCom:"", CodDpt:""}, {Type:"", PrenomPsn, NbVoix:"", RapportExprime: "",LibSubCom:"", CodDpt:""}]}

    This does not match what you are sending from your file.

  • Charly232Charly232 Posts: 2Questions: 0Answers: 0

    Hello thank's for you're replie.

    That's not solved my problem i have tried to indicate my data source with "dataSrc" with no success...

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Changing your dataSrc is not enough. Your datatable data structure just does not match the data in fe-xml.txt produced by your php. Your datatable cannot find the data to display

    Data Structure

            [{
                "Scrutin": { "Type": "Pr\u00e9sidentielle", "Annee": "2012" },
                "Tour": {
                    "NumTour": "1", "Date": { "Jour": "22", "Mois": "04", "Annee": "2012" },
                    "Mentions": { "Inscrits": { "Nombre": "46028542" }, "Abstentions": { "Nombre": "9444143", "RapportInscrit": "  20,52" }, "Votants": { "Nombre": "36584399", "RapportInscrit": "  79,48" }, "BlancsEtNuls": { "Nombre": "701190", "RapportInscrit": "   1,52", "RapportVotant": "   1,92" }, "Exprimes": { "Nombre": "35883209", "RapportInscrit": "  77,96", "RapportVotant": "  98,08" } },
                    "Resultats": {
                        "ListesCandidats":
                            {
                                "Candidat": [
                                  { "NumPanneauCand": "1", "NomPsn": "JOLY", "PrenomPsn": "Eva", "CivilitePsn": "Mme", "NbVoix": "828345", "RapportExprime": "   2,31" },
                                  { "NumPanneauCand": "2", "NomPsn": "LE PEN", "PrenomPsn": "Marine", "CivilitePsn": "Mme", "NbVoix": "6421426", "RapportExprime": "  17,90" },
                                  { "NumPanneauCand": "3", "NomPsn": "SARKOZY", "PrenomPsn": "Nicolas", "CivilitePsn": "M.", "NbVoix": "9753629", "RapportExprime": "  27,18" },
                                  { "NumPanneauCand": "4", "NomPsn": "M\u00c9LENCHON", "PrenomPsn": "Jean-Luc", "CivilitePsn": "M.", "NbVoix": "3984822", "RapportExprime": "  11,10" },
                                  { "NumPanneauCand": "5", "NomPsn": "POUTOU", "PrenomPsn": "Philippe", "CivilitePsn": "M.", "NbVoix": "411160", "RapportExprime": "   1,15" },
                                  { "NumPanneauCand": "6", "NomPsn": "ARTHAUD", "PrenomPsn": "Nathalie", "CivilitePsn": "Mme", "NbVoix": "202548", "RapportExprime": "   0,56" },
                                  { "NumPanneauCand": "7", "NomPsn": "CHEMINADE", "PrenomPsn": "Jacques", "CivilitePsn": "M.", "NbVoix": "89545", "RapportExprime": "   0,25" },
                                  { "NumPanneauCand": "8", "NomPsn": "BAYROU", "PrenomPsn": "Fran\u00e7ois", "CivilitePsn": "M.", "NbVoix": "3275122", "RapportExprime": "   9,13" },
                                  { "NumPanneauCand": "9", "NomPsn": "DUPONT-AIGNAN", "PrenomPsn": "Nicolas", "CivilitePsn": "M.", "NbVoix": "643907", "RapportExprime": "   1,79" },
                                  { "NumPanneauCand": "10", "NomPsn": "HOLLANDE", "PrenomPsn": "Fran\u00e7ois", "CivilitePsn": "M.", "NbVoix": "10272705", "RapportExprime": "  28,63" }]
                            }
                    }
                }
            }, 128]
    
    
    

    Definition:



    $("#exemple").DataTable( { "ajax": "http://www.pcarm.fr/com/donnees/fe-xml.txt", "columns": [ { "data": "Type" }, { "data": "PrenomPsn" }, { "data": "NbVoix" }, { "data": "RapportExprime" }, { "data": "LibSubCom" }, { "data": "CodDpt" }, ] });
This discussion has been closed.