Hey all I currently have the following JSON returned when calling my ajax coldfusion .cfc page:
"[{\"USERA\": \"LiveP\", \"STATE\": \"None Given\", \"ROLES\": \"District Administrator<br/>Personnel Admin<br/>**** Coordinator\", \"ROLEASSIGNED\": \"LG AdminPersonnel System\", \"ADDRESS\": \"None Given\", \"UPDATEURL\": \"/personnel/search_ajax.cfc?func=edit=2*******\", \"TELEPHONE\": \"None Given\", \"ADDRESS2\": \"None Given\", \"ZIPCODE\": \"None Given\", \"LOCATION\": \"<a href=\\\"locations.cfm?func=view&locationID=\\\"2*******\\\">Demo New School (Primary)</a>\", \"SYSTEMID\": 87024, \"HOMETELEPHONE\": \"None Given\", \"MANAGEURL\": \"tools.cfm?userID=2*******\", \"MERGEURL\": \"/personnel/search_ajax.cfc?func=merge&userID=2*******\", \"EMAIL\": \"noaddress@noaddress.com\", \"SUBJECTTAUGHT\": \"None Given\", \"CITY\": \"None Given\", \"POSITION\": \"None Given\"}]"
When I run this code below it gives me the above JSON:
success: function(data) {
var sData = JSON.stringify(data);
console.log(sData);
},
Now if I do not use JSON.stringify then my output is:
[Object]
What I am ultimatlly looking to do is loop through this returned JSON and get the key and value without needing to know the key (a.k.a. sData.Address, sData.Address2, sData.City, etc etc).
I plan on putting it in this type of format:
var theHTML = "";
$.each(data,function(key,value){
theHTML += "<tr><td>" + key + "</td><td>" + value + "</td></tr>";
})
Which that only returns:
<tr><td>0</td><td>[object Object]</td></tr>
I'm sure I'm just missing something little but I just can't find what that is.