Problem with ajax/data

Problem with ajax/data

sonobroccosonobrocco Posts: 6Questions: 2Answers: 0
edited May 2014 in DataTables

Hi all,

this is my first post here...
First of all, I started using this feature few weeks ago and I found it really good!!!

Now my question:
I have an asp page returning a json text (I use JSON_UTIL.asp file and the Flush function). If I execute the page it returns a well formed json structure.
I don't know how can I make this structure to be read and executed by DataTables....

Could you please help?

Thanks in advance

P.S: My structure looks like:

[
  {
    "nomeTabella": "Ricerca Immobili 1",
    "datarif": "02/04/2014",
    "categoriac": "100",
    "descrizion": "la vispa teresa",
    "prov_Comune": "VR"
  },
  {
    "nomeTabella": "Ricerca Immobili 2",
    "datarif": "03/04/2014",
    "categoriac": "123",
    "descrizion": "via le mane dal ...",
    "prov_Comune": "MI"
  },
  {
    "nomeTabella": "Ricerca Immobili 3",
    "datarif": "04/04/2014",
    "categoriac": "111",
    "descrizion": "fate i afari toi",
    "prov_Comune": "NA"    
  },
  {
    "nomeTabella": "Ricerca Immobili 4",
    "datarif": "04/02/2014",
    "categoriac": "101",
    "descrizion": "la vispa teresa 2",
    "prov_Comune": "VI"
  },
  {
    "nomeTabella": "Ricerca Immobili 5",
    "datarif": "31/01/2014",
    "categoriac": "132",
    "descrizion": "via le mane dal ... 2",
    "prov_Comune": "LO"
  },
  {
    "nomeTabella": "Ricerca Immobili 6",
    "datarif": "01/05/2014",
    "categoriac": "222",
    "descrizion": "fate i afari toi 2",
    "prov_Comune": "SA"    
  }    
]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 54,529Questions: 1Answers: 8,526 Site admin
    Answer ✓

    Use the ajax.dataSrc option and set it to be an empty string - that tells DataTables to read an array of data from the Ajax request. Then use columns.data to tell DataTables what property to use for each column.

    Allan

  • sonobroccosonobrocco Posts: 6Questions: 2Answers: 0

    Thank, it perfectly works!!! ;)

This discussion has been closed.