1

i want to display json data from online URL to HTML table?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>JSON Sample</title>
</head>
<body>
    <div id="placeholder"></div>
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script>
  $.getJSON('test.json', function(data) {
        var output="<ul>";
        for (var i in data.items) {
            output+="<li>" + data.items[i].Id + " " + data.items[i].name + "--" + data.items[i].old+"</li>";
        }

        output+="</ul>";
        document.getElementById("placeholder").innerHTML=output;
  });
    </script>
</body>
</html>

how i can change test.json with online URL ? its doesn't show any result can you please help me

7
  • please write some code, which you have tried yet Commented Jun 4, 2014 at 10:29
  • please find my updates Commented Jun 4, 2014 at 10:36
  • Try attaching an error handler and see what it says. It's likely either a parsing error (bad JSON) or a network error (bad url). Commented Jun 4, 2014 at 10:40
  • "test.json" should be in same domain Commented Jun 4, 2014 at 10:49
  • Did you check this link? api.jquery.com/jquery.getjson. Example with online url works fine Commented Jun 4, 2014 at 11:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.