This is the way I handle an Ajax response. I am sure it can be improved.
success: function (json) {
$.each(json, function(index,item){
if (item.field == "article_id") {
$("#article_id").val(item.value);
} else if (item.field == "naslov") {
$("#naslov").val(stripslashes(item.value));
}else if (item.field == "slug_naslov") {
$("#slug_naslov").val(item.value);
}else if (item.field == "datum") {
$("#datum").val(item.value);
}else if (item.field == "url") {
$("#url").val(item.value);
}else if (item.field == "tekst") {
$("#tekst").val(stripslashes(item.value));
}else if (item.field == "tag_title") { //handle tags - tokeninput
var tagoviArray = item.value;
var tagoviInput = $("#txtTags");
$(tagoviInput).tokenInput("clear");
$.each(tagoviArray, function (index, value) {
var arr = value.split(',');
$.each(arr, function (i, v) {
if (!(v=="")) {
$(tagoviInput).tokenInput("add", {id: "", name: v}); tag
}
});
});
}else if (item.field == "love") {
$("#love").val(item.value);
}
});
return false;
}