I’m iterating through my JSON response. I’ve got HTML elements with id’s as the parameter names.
For example, my JSON response contains a "costcenter":"1234", and there’s a <span> element with the id costcenter.
Now, instead of writing a statement for every id, I thought I could iterate through the JSON array, and automatically read its name.
This is what I got
$(".dataset").click(function() {
changeid = this.id;
$.ajax({
url: "source",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: {
id: changeid
},
success: function(data) {
// How to get the name of the parameter, and then read it's value?
}
})
})
The JSON looks like that, it’s just one dimension and 1 result set only:
{"changeid":"1","costcenter":"478","manager":"John Smith"}
If I understand your question you want something like that in your success function :