jquery - How to read json from url in javascript? -
i working on json server in javascript.
i used pure javascript, jquery getting status 0.
$(document).ready(function() { $("#btn").click(function(event){ $.getjson('http://myhost/myapp/data.json', function(jd) { alert(jd); }); }); }); <body> <input type="button" id="btn" value="load data" /> </body>
getjson()
block not called.
can me?
check if allow cors on host or if response empty!
you might try use $.ajax()
.
$.ajax("http://myhost/myapp/data.json", function (data) { console.log(data); }
Comments
Post a Comment