How to process a JSON list to HTML
My plan is to generate with PHP a list of image properties like
- "images": [
- { "imageURL":"images/5566_120512.jpg" , "alt":"Filler", "caption":"Caption" },
- { "imageURL":"images/5571_120520.jpg" , "alt":"Filler", "caption":"Caption" },
- { "imageURL":"images/5572_120530.jpg" , "alt":"Filler", "caption":"Caption" }
- ]
I am not sure about how to process the list with AJAX to produce
- <a href="images/5566_120512.jpg" title="Filler"><img src="images/thumb/5566_120512.jpg" alt="Filler" caption="Caption"/></a>
- <a href="images/5571_120512.jpg" title="Filler"><img src="images/thumb/5571_120512.jpg" alt="Filler" caption="Caption"/></a>
- <a href="images/5572_120512.jpg" title="Filler"><img src="images/thumb/5572_120512.jpg" alt="Filler" caption="Caption"/></a>
The thumbnails have the same URL except that they will be in the sub-directory, thumb.
I believe I understand the basic AJAX syntax e.g.
- $(document).ready(function() {
- $.ajax({
- type: "GET",
- url: "json/mages.json", //json file
- dataType: "json",
- success: function(json) {
- }
- )}
- )}
Though I am not sure about the dataType being "json".
Is there a reference that I have overlooked that discusses this topic?
Todd