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

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -