解析 JSON 文件并以 HTML 格式显示 [英] Parsing JSON file and displaying in HTML

查看:40
本文介绍了解析 JSON 文件并以 HTML 格式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以 json 形式向 jquery 获取数据,但无法以 HTML 显示.我不想使用 jquery 来显示.我可以在 HTML 中访问 jquery 变量吗?如果可能,请帮助我.

I am getting data to jquery in json form but not able to display in HTML. I don't want use jquery to display. can i access jquery variable in HTML. Please help me, if this possible.

<script type=text/javascript>
$(function() {
  $('#result').bind('input', function() {
    $.getJSON('/prescription1', {
      a: $('input[name="a"]').val()
    }, function(data) {
        console.log(data);
    });
    return false;
  });
});

推荐答案

不,您不能使用 HTML 访问 jquery 数据.HTML 是一种标记语言,这意味着您可以将 html 用于

No, you can't access jquery data using HTML. HTML is a markup language, this means that you can use html for

以语法上的方式注释文档与文字区别.

annotating a document in a way that is syntactically distinguishable from the text.

现在,如果您想避免使用 jQuery,那么您的问题有一个普通的 javascript 解决方案,但您必须使用 javascript.

Now, if you want to avoid jQuery there is a vanilla javascript solution for your problem but you have to use javascript.

您可以在 Quora 上阅读此问题以了解网络语言之间的差异:https://www.quora.com/What-are-the-differences-between-HTML-XML-PHP-CSS-and-JavaScript-in-外行条款

You can read this question on Quora to understand the differences between web languages: https://www.quora.com/What-are-the-differences-between-HTML-XML-PHP-CSS-and-JavaScript-in-layman-terms

这篇关于解析 JSON 文件并以 HTML 格式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆