javascript - relative path method to read external json file with jquery -
as showen on title want read json file in jquery relative path method. first of all, beginer on job , it's can stupid thing try.
i have external json file, want turned file in script. json file must have external because of, can changed somereason after developing , regular changing according process.
here json file.
{ "revisiondate": "21 april 2016", "documentname": "1658mc", "department": "sales", "description": "available", "link": "href=1658mc.pdf" }, { "revisiondate": "16 april 2016", "documentname": "vcx16b", "department": "enginnering", "description": "not available", "link": "href=vcx16b.pdf" }, { "revisiondate": "15 march 2016", "documentname": "ab36f", "department": "custumer services", "description": "not available", "link": "href=ab36f.pdf" }, { "revisiondate": "12 agust 2016", "documentname": "fc25d", "department": "technical support", "description": "not available", "link": "href=fc25d.pdf" }
and json file saved local file
c:.......\desktop\deneme16\deneme161.json
to read file script
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <table id="userdata" border="0.02"> <th>revision date</th> <th>document name</th> <th>department </th> <th>description</th> <th>link</th> </table> <script> $.ready(function() { myobjects = {}; $.getjson('deneme16.json', function(data) { myobjects.myjson = data; }); $.each(data.person, function(i, person) { var tblrow = "<tr><td>" + person.revisiondate + "</td><td>" + person.documentname + "</td><td>" + person.department + "</td><td>" + person.description + "</td><td><a target='_blank' href='" + person.link.split('href=')[1] +"' >"+person.link.split('href=')[1] +"</a></td></tr>" $(tblrow).appendto("#userdata tbody"); }); }); </script> </body> </html>
how can read local file jquery? read lot of tittle title talking ajax.request someones talking parse.jquery , someones talknig not possible because of security policty. tried lot of thing , decided write codes. confused , want solve problem. can explaşn problem oparete code
surucundeki dosyalara javascript ile erisemezsin. guvenlik acigi nedeniyle hemen hemen butun browserlardan kaldirildi. ajax ile server'daki dosyalara erisip, json.parse(jsonstring) seklinde okuyabilirsin.
Comments
Post a Comment