Unable to fetch Json data from remote url
Posted
by
user3772611
on Stack Overflow
See other posts from Stack Overflow
or by user3772611
Published on 2014-08-20T16:18:23Z
Indexed on
2014/08/20
16:19 UTC
Read the original article
Hit count: 190
I am cracking my head to solve this thing. I am unable to fetch the JSON data from remote REST API. I need to fetch the JSOn data nd display the "html_url" field from the JSON data on my website. I saw that you need the below charset and content type for fetching JSON.
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="application/json">
</head>
<body>
<p>My Instruments page</p>
<ul></ul>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
alert("Inside the script");
$.getJSON(" https://pki.zendesk.com/api/v2/help_center/sections/200268985/articles.json", function (obj) {
alert("Inside the getJSON");
$.each(obj, function (key, value) {
$("ul").append("<li>" + value.html_url + "</li>");
});
});
});
</script>
</body>
</html>
I referred to following example on jsfiddle http://jsfiddle.net/2xTjf/29/
The "http://date.jsontest.com" given in this example also doesn't work in my code. The first alert is pops but not the other one.
I am a novice at JSON/ Jquery. i used jsonlint.com to find if it has valid JSON, it came out valid.
I tested using chrome REST client too.
What am I missing here ?
Help me please !
Thanks in anticipation.
© Stack Overflow or respective owner