I am calling a webservice using jQuery/AJAX which returns a string array (string[]).
This is my response:
{"GetTagsResult":["acceleration","aktantmodellen","ampere","analyse","analyseeksempel","atmosfæren","best practice","boganmeldelse","brændtrekanten","cellemembran"]}
I want to get the list out in a variable, so I only operate on the list and not the “GetTagsResult” key name.
This is my call:
$(document).ready(function () {
$("#myabtags").tagit({
tagSource: function (request, response) {
$.ajax({
type: "POST",
url: "Services/ForumOperationService.svc/GetTags",
datatype: "json",
contentType: "application/json; charset=utf-8",
data: {},
success: function (data) {
response(data);
}
});
},
removeConfirmation: true
});
});
I have tried the following things on response(data) line:
- response(data.d)
- response(data.value)
- response(data[0].value)
But nothing helps.
I want to get the following out in the variable instead:
["acceleration","aktantmodellen","ampere","analyse","analyseeksempel","atmosfæren", "best practice","boganmeldelse","brændtrekanten","cellemembran"]
You array is in
You may also get it with
So you may call
This MDN guide might help : Working with objects