javascript - getting json data loop -


Hello IAC: I have a problem: I am coming from some data JSON file, and I have to write it more efficient ways Actually, this work is fine, but I would like to give images like nested arrays or some things.

So I only have to call an image tag, but the image tag will be set in the set. I do not want to define the image1-image1000 img tag,

Should be able to insert in images like:

  one ??? ? Image: image: {image1.jpg, image2.jpg, image3.jpg, image4.jpg}   

and call it with an image tag like this < P> is it possible ??? Some guidance will be helpful Thanks

  JSON DATA {"mygallery": [{"image1": "image1.jpg", "image2": "image2.jpg", "image3": " Image 3.jpg "," Image4 ":" Image 4.jpg "," Panjemea ":" MyGallery "," Javascript Call "and" Script Type = "Text / JavaScript" & gt; $ .getJSON ('js / gallery .js, function {$ ("# main") .html (''); $ (data.magallery) .each (function (index, mygalary) {$ ("# main"). Attachments (' Lt; li class = "thecontent">  
IMG src = "/ _ img / '+ mygallery Image2 + '' /> & Lt; img src = "/ _ img / '+ mygallery.image3 +'" /> gt; & lt; img src = " / _ Img / '+ mygallery.image4 +' "/> '+ Mygallery.pagename +' & lt; / li & gt; ');} );}); & Lt; / scripts & gt; HTML DIV & lt; div id = a 'main' ??? & Gt; & lt; / div & gt;

You can create something like this Which still holds all images and pagename inside mygallery item.

  {"mygallery": {Images: ["image1.jpg", "image2." Jpg "," image3.jpg "," image4.jpg ",], Penneam: a ??? MyGalleryĆ¢ ????}}   

in this way you will use it

  $. GetJSON ('js / gallery.js', function (data) {$ ("Html ('
  • '); // $. Each (Imag function (index, image) {// $ (" # ("& lt; span & gt; '+'); $ (" # Main "). ('& Lt; img src =" / _ img /' + + image + '"/ & gt;'); data. Pagename + '

  • Comments

    Popular posts from this blog

    mysql - BLOB/TEXT column 'value' used in key specification without a key length -

    c# - Using Vici cool Storage with monodroid -

    python - referencing a variable in another function? -