1

I'm not able to access _sValues in my html page, however i can able to console.log the interested _sValues array element in console.

JSON

[
    {  
      "_this":{  
         "_isEvent":false,
         "_sNames":[  
            "name",
            "tag",
            "notes",
            "input",
            "type",
            "action"
         ],
         "_sValues":[  
            "Testing01",
            "#13",
            "1504013826",
            "No details",
            "cType",
            "NA"
         ],
         "_cName":"namesList",
         "_dName":"TEST",
         "_id":"12345",
      }
   }
]

HTML

<th class="col-md-5 col-xs-5" data-field="_this._sValues[1]" data-sortable="true">S-VALUES</th>

I would like to see #13 displayed on the page instead i don't see any values or console error. However i can display all values by doing _this.sValues

SCRIPT

var data;
$(function () {
    $.getJSON("http://localhost:8080/services/webapi/getAllData", function(json){
       data = json;
       $('#table').bootstrapTable({
          data: data
       });
    });
});

DEV TOOL

data[0]._this._sValues[1]
"#13"
2
  • How are you trying to inject the value from your javascript into the html? Commented Aug 30, 2017 at 3:33
  • @quickshiftin updated the question with script function Commented Aug 30, 2017 at 3:37

2 Answers 2

1

In your case, i assume you only have one row.

$(".col-md-5").attr("data-field",data[0]._this._sValues[1]);

It will inject the data to html. If you have multi row, you can use for loop.

Sign up to request clarification or add additional context in comments.

Comments

1

I believe you have a silent error. It has to do with the trailing comma in your data object.

 "_id":"12345",

// should be

 "_id":"12345"

That's all I noticed. I Courbet wrong but I know trailing commas mess with some browsers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.