jquery - getting data from json file -


I have a json file named "json.json" in the directory. I want to get items from that file and display them in UL, which I have coded hard till now When I try to get that file it is not working Does anyone help me retire and add those items to ul in JSO file thanks in advance

  & Lt ;; Doctype html & gt; & Lt; Html lang = "en" & gt; & Lt; Top & gt; & Lt; Title & gt; Example & lt; / Title & gt; & Lt; Link rel = "stylesheet" href = "// code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css"> & Lt; Script type = "text / javascript" src = "js / jquery.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "js / jquery_ui.js" & gt; & Lt; / Script & gt; & Lt; Link rel = "stylesheet" href = "/ resources / demos / style.css" & gt; & Lt; Link rel = "stylesheet" href = "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" & gt; & Lt; Link rel = "stylesheet" href = "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css" & gt; & Lt; Script src = "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Table id = "myTable" class = "table-table-range" & gt; & Lt; TR & gt; & Lt; Th class = "call-MD-6 text-center success" & gt; List 1 & lt; / Th & gt; & Lt; Th class = "call-MD-6 text-center hazard" & gt; List 2 & lt; / Th & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td square = "call-MD-6" & gt; & Lt; Ul id = "first list" & gt; & Lt; Li & gt; Apple & lt; Img id = "Apple" src = "next.jpg" category = "list1" & gt; & Lt; / Li & gt; & Lt; Li & gt; Orange & lt; Img id = "orange" src = "next.jpg" class = "list1" & gt; & Lt; / Li & gt; & Lt; Li & gt; Avacado & lt; Img id = "avacado" src = "next.jpg" class = "list1" & gt; & Lt; / Li & gt; & Lt; Li & gt; Banana & lt; Img id = "banana" src = "next.jpg" class = "list1" & gt; & Lt; / Li & gt; & Lt; Li & gt; Mango & lt; Img id = "common" src = "next.jpg" class = "list1" & gt; & Lt; / Li & gt; & Lt; Ul & gt; & Lt; / TD & gt; & Lt; Td square = "call-MD-6" & gt; & Lt; Ul class = "seclist" id = "seclist" & gt; & Lt; / Ul & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Script & gt; $ (Function () {$ .getJSON ('json.json', function) {console.log ('success');}) error (function () {console.log ('error');}) ;}); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

I created the Jason file like this:

  {"fruits": [{"text toddispled": "apple"}, {"text tubidispled ":" Orange "}, {" Text tobeispled "}:" avacado "}, {" text tobes displayed ":" banana "}, {" text todispled ":" common "},]}    

You must specify the json array in a variable. The suggestion of LittleDragon is correct, but you have to use it like this:

  var fruits = {"fruits": [{"text tobs displayed": "apple"}, {"text to Beespled ":" orange "}, {" text toddispled ":" avacado "}, {" text tobes display ":" banana "}, {" text toddspled ":" mango "},]};   

And then just click & lt; Script src = "json.json" & gt; & Lt; / Script & gt; Add, then you have the fruits json array from javascript.

It's a bell for you:

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -