如何将 json url 显示到 html
How to display json url to html?
我在jquery中很慢,我试图研究如何将json文件从url显示到html,但似乎我没有收到代码。我只想在这里显示这个 json 数据:http://api.paperstreetjobs.com/exam/show/getProblems
我想向我的 html 显示数组中的每个问题和难度值。
我的 json:
[
[
{
"id":26,"question":"What html element will the following CSS code selects?'r'n'r'nli:not(#foo) > fieldset > div > span > input[type='radio'], 'r'nli:not(#foo) > fieldset > div > span > input[type='checkbox']",
"note":"",
"difficulty":"easy",
"language":"css"
}
],
[
{
"id":18,"question":"Try to figure out what is wrong with the codes below. Explain your answer'r'n'r'n",
"note":"",
"difficulty":"average",
"language":"php"
}
],
[
{
"id":112,
"question":"Assuming there is a sample.json file inside your directory. That contains'r'n{'"1'":{'"id'":1,'"clicks'":100,'"stars'":5},'"2'":{'"id'":2,'"clicks'":120,'"stars'":2},'"3'":{'"id'":3,'"clicks'":60,'"stars'":3}}'r'n 'r'nGet the value of the json file'r'nSort the values according to its 'u201cstars'u201d descending and 'u201cclicks'u201d descending.'r'nReplace the sample.json content to the sorted value assuming that the file is writable.'r'nAssuming that the values changes once a day, your code should adopt to the values of 'u201cclicks'u201d and 'u201cstars'u201d",
"note":"",
"difficulty":"hard",
"language":"php"
}
]
]
请帮助我并指导我。 提前感谢!
这很简单。
$.get( "http://api.paperstreetjobs.com/exam/show/getProblems", function( data ) {
$( ".result" ).html( data );
alert( "Load was performed." );
});
您可以使用@Deep代码来呈现它。
最好
叶戈尔
这是完整 ajax 查询的回调代码:
var
itemsBox = $('#items-box'),
i;
for (i = 0; i < yourJSON[0].length; i++) {
itemsBox.append(''
+ '<div>id: ' + yourJSON[i][0].id + '</div>'
+ '<div>question: ' + yourJSON[i][0].question + '</div>'
+ '<div>note: ' + yourJSON[i][0].note + '</div>'
+ '<div>difficulty: ' + yourJSON[i][0].difficulty + '</div>'
+ '<div>language: ' + yourJSON[i][0].language + '</div>'
);
}
相关文章:
- Brightcove获取/显示HTML中的当前视频标题和描述
- HTML 标记未在 AngularJS ckEditor 中应用,而是在 Ediator 中显示 HTML 元素标记代码
- 使用jqLite隐藏和显示html元素
- 如何在不打断标记的情况下突出显示html字符串中的文本
- JS来显示HTML标记
- 如果javascript打开/关闭,则隐藏和显示html代码
- 用javascript显示html表
- 显示HTML代码块
- Regex有助于突出显示html中匹配文本的角度过滤器
- 为什么WebBrowser控件在保存后不能正确显示HTML
- 如何通过ibmworklight中的sql适配器从db2中检索或显示html页面上的数据?android混合应用程序开发
- 如何使用window.showModalDialog()显示HTML内容
- JavaScript if else 语句来显示 html 标签
- 使用 js 函数显示 HTML 表单的结果
- 如何在不点击的情况下突出显示 HTML 中的文本
- 如何隐藏和显示 html 输入文本和段落
- 使用 javascript 解析和显示 HTML 音频当前时间
- 有什么方法可以在HTML页面中显示HTML代码吗
- 在自动完成jqueryUi中显示html
- 单击并用CTRL+C复制值时高亮显示html表格单元格