Original question was to parse a list of topics, however starting with the original example to have a function return a single value may also useful. To that end, here is an example of (one way) to do that:
<script type='text/javascript'>
function getSingleValueUsingJQuery() {
var value = "";
var url = "rest/endpointName/" + document.getElementById('someJSPFieldName').value;
jQuery.ajax({
type: 'GET',
url: url,
async: false,
contentType: "application/json",
dataType: 'json',
success: function(json) {
console.log(json.value); // needs to match the payload (i.e. json must have {value: "foo"}
value = json.value;
},
error: function(e) {
console.log("jQuery error message = "+e.message);
}
});
return value;
}
</script>