How to read json from url to javascript?


I am working on get json from server in javascript.

i used pure javascript, jquery but i am getting status 0.

$(document).ready(function() {
        $.getJSON('http://myhost/myapp/data.json', function(jd) {

    <input type="button" id="btn" value="Load Data" />

getJSON() block not called.

can anyone help me?

Check if you allow CORS on your host or if your response was empty!

You might also try to use $.ajax().

$.ajax("http://myhost/myapp/data.json", function (data) {