Getting row's data

Getting row's data

hitostachahitostacha Posts: 5Questions: 2Answers: 0

I'm basically doing a copy-pasta of this:
https://datatables.net/examples/ajax/null_data_source.html

But whenever I click on one of my buttons, all I get is:
I'm loading my data with a json array of objects, if that helps, whenever I try to alert the desired row's column data (ID) with the name of the json object I load, it retrieves the ID of that row, but whenever I try to do it with an array position, undefined is what shows up.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586
    Answer ✓

    Hi @hitostacha ,

    Without seeing your code, it's most likely caused by what you said - the fact that you're loading the data from an object.

    In the example you referenced, the code is:

    alert( data[0] +"'s salary is: "+ data[ 5 ] );
    

    You'll need to change the number references to be the field name, i.e. something like:

    alert( data['name'] +"'s salary is: "+ data['salary'] );
    
    

    Cheers,

    Colin

This discussion has been closed.