Json with Jquery

Today, I am think about ornagai api. I should export with JSON because json is easy to read data with javascript library (mootools,jquery,etc..) and also with PHP. So, I tring with Jquery to read json. Oh! it’s so easy and so nice for me.

This is a data.json






“def”:”     the first letter of the English alphabet”





“def”:”the quality, production, expression, or realm, according to aesthetic principles, of what is beautiful, appealing, or of more than ordinary significance”






“def”:”an ancient Roman god of agriculture, the consort of Ops, believed to have ruled the earth during an age of happiness and virtue, identified with the Greek god Cronus.”



This is my jquery code

[sourcecode lang=’js’] $(function() { $.getJSON(“data.json”, function(json) { alert(json.data[1].def); $.each(json.data,function(i,mydata){ $(“#result”).append(mydata.word+”<br>”); }); }); }); [/sourcecode]

Complete HTML code is

[sourcecode lang=’xhtml’] <html>


<script src=”jquery-1.3.2.min.js”></script>


$(function() {

$.getJSON(“data.json”, function(json) {






}); </script>



<div id=”result”>



</html> [/sourcecode]

Download Complete source code

comments powered byDisqus