Using the following code, I am getting the json array string in the div (named remoteFeed)
Say it shows:
{"id":"25","name":"Basil","country":"USA"}
My question is how can I get the json array elements?
Pl note that even though it shows the value in the div -- the alert (see below) shows blank!!!
alert(data); //-------------------Shows blank
NB: Being a newbie I was trying to get the value first. But in this case we have to convert it to json object. So if you know a better way, so that I get the values (id, name..) on the client side that is more advisable
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
(function ($) {
$(document).ready(function(){
$('#remoteFeed').load('http://testservice/json/');
var data = remoteFeed.innerHTML;
alert(data); //-------------------Shows blank
/*
var jsonObj = JSON.stringify(eval("(" + data + ")"));
for(var i in jsonObj)
{
var id = data[i].country_code;
alert(id);
}
*/
});
})(jQuery);
var data = remoteFeed.innerHTML;
alert(data);
</script>
</head>
<body>
<div id="remoteFeed"></div>
</body>
.load()