Webservice JSON data not showing in HTML ID's. | XM Community
Skip to main content
Question

Webservice JSON data not showing in HTML ID's.

  • May 22, 2020
  • 2 replies
  • 16 views

Forum|alt.badge.img+1

Hello,
We developed our own webservice which we query and set as embedded data in a field called

sample.0
. We know the call works because the embedded data fields show up when we generate test responses. This field looks like this (but repeated 50 times for 50 loop & merge tasks)
[{feature:Star Wars: Rebels,topic:movies_tv_shows,label:Movie or TV-Show},{feature:Hereditary,topic:movies_tv_shows}]
We then have this in the JS:


var task = parseInt("${lm://Field/1}");

var featuresJson = "${e://Field/sample.0}"

var features = JSON.parse(featuresJson);

/* tried jquery */
jQuery("#feature").html(features[task-1].feature);

/* also tried my elementID */
document.getElementById("feature").innerHTML = features[task-1].feature;
And this in the HTML to display the values one by one:
Do you like
However, I cannot get any of the elements to show up. I also tried just showing the task we're in from this field but I can't get anything to show in the question text.

2 replies

Forum|alt.badge.img+2
  • Level 2 ●●
  • May 26, 2020

i will add console.log("featuresJson",featuresJson) after reading the sample.0
var featuresJson = "${e://Field/sample.0}"
console.log("featuresJson",featuresJson)
just to make sure i can read featureJson


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • May 26, 2020

Instead of:
features[task-1].feature
Try:
features[task-1]['feature']