My controller has a method that is returning string representation of a jsonArray as
jsonArray.toString()
Now following is the ajax method
function loadPropertyFile(url) {
$.ajax({
type: "GET",
url: url,
dataType: "text",
success: function(response){
var obj = jQuery.parseJSON(response);
alert(obj);
}
});
}
Here the variable obj after parsing comes out to be
"[{"portal.home":"Home"},{"displaytag.tracking.id":"Item ID"},{"displaytag.tracking.itemName":"Item Name"},{"displaytag.tracking.itemType":"Type"}]"
Now I want to access the values from the keys in js
ie. I want to access the value of key "displaytag.tracking.id"
Problem is when I am doing console.log(obj[0]["portal.home"]); It is giving me error TypeError: obj[0] is undefined
What shall I do ?
'[{"portal.home":"Home"},{"displaytag.tracking.id":"Item ID"},{"displaytag.tracking.itemName":"Item Name"},{"displaytag.tracking.itemType":"Type"}]'remove the double quotes at front and at end use single quotes