0

我想使用 Jquery & Ajax 将 Json 数据存储到表中。这是我的 Json 文件,如下所示:-

[
{
"term": "BACCHUS",
"part": "n.",
"definition": "A convenient deity invented by the ancients as an excuse for getting drunk.",
"quote": [
"Is public worship, then, a sin,",
"That for devotions paid to Bacchus",
"The lictors dare to run us in,",
"And resolutely thump and whack us?"
],
"author": "Jorace"
},
{
"term": "BACKBITE",
"part": "v.t.",
"definition": "To speak of a man as you find him when he can't find you."
},
{
"term": "BEARD",
"part": "n.",
"definition": "The hair that is commonly cut off by those who justly execrate the absurd Chinese custom of shaving the head."
}
]

我有一个名为“json”的表,其中三列的名称分别为术语、部分和定义。现在我刚刚像这样将 json 数据加载到 html 表中。

   $.ajax({
        type: "GET",
        url: "b.json",
        dataType: "json",
        success: function (data) {
            $.each(data, function (entryIndex, entry) {
                //   var html = '<div class="declareing_variable">';
                var html1 = entry['term'];
                var html2 = '<div class="geting_part">' + entry['part'] + '</div>';
                var html3 = '<div class="geting_definition">' + entry['definition'] + '</div>';
                $('<tr></tr>').html('<th>' + html1 + '</th><th>$' + html2 + '</td><th>$' + html3 + '</th>').appendTo('#json');
                $('#abc').append(html2);

            });
        }
    });

谁能告诉我如何将它存储到 sql 表中并可以提供一些编码帮助?

4

1 回答 1

0

你的服务器端编程语言是什么?

如果那是 PHP,您可以使用 JSON_DECODE() 来解码您发送到 Web 服务器的 json 数据: PHP 网站上的 json_decode()

但是,由于您使用的是 C#,因此您需要在 Codeplex 上使用类似 JSON 库之类的东西来解码您的 JSON。

于 2012-09-05T05:12:30.077 回答