用JSON显示图像

用JSON显示图像,json,image,Json,Image,我试图学习如何使用JSON,但我被卡住了。 现在我想在单击图像时显示图像。 我觉得我很接近,但不知道怎么了。 另外,这是用JSON显示图像的正确方法吗?(" html: <nav> <ul> <li><a id="boek1" href="#">Boek 1</a></li> <li><a id="boek2" href

我试图学习如何使用JSON,但我被卡住了。 现在我想在单击图像时显示图像。 我觉得我很接近,但不知道怎么了。 另外,这是用JSON显示图像的正确方法吗?(" html:

<nav>
            <ul>
                <li><a id="boek1" href="#">Boek 1</a></li>
                <li><a id="boek2" href="#">Boek 2</a></li>
            </ul>
</nav>

data.books[0].cover[0]
这是用JSON显示图像的正确方法吗?你是说javascript吗?JSON只保存数据,无法处理逻辑。也许你正在寻找一种使用方法?首先尝试对ajax成功数据进行控制台。books[0].cover[0].source,如果您想学习json,此链接非常有帮助,我想请尝试首先对ajax成功数据进行控制台操作。书籍[0]。封面[0]。源代码。如果您想学习json,此链接非常有帮助,我想感谢大家,它起到了作用
   $(document).ready( function()
    {
        $('#boek1').click(function(event)
        {
            event.preventDefault();

            $.ajax(
            {
                url:        'Booklist.json',
                dataType:   'json',
                success:    function(data)
                {   
                    $('#content').append('<img src="'data.books.cover[0].source'">');
                    console.log(item);
                },
                error: function()
                {
                    alert("Houston, we have a problem");
                }   
            });             
        });
    });
{
    "books": [
        {
            "title": "HTML5 Media, Integrating audio and video with the Web",
            "author": "Shelley Powers",
            "desc": "A detailed introduction to presenting audio and video in HTML5, from markup through scripting. It will explain not just placing content in pages but interaction through Javascript APIs, to build media players that could be used cross-browser.",
            "publishDate": "July 2011",
            "url": "http://oreilly.com/catalog/0636920019824/",
            "cover": [
                {
                    "type": "bigCover",
                    "source": "img/cat_005.gif",
                    "alternative": "HTML5 Media"
                },
                {
                    "type": "cover",
                    "source": "img/bkt_005.gif"
                }
            ]
        },
        {
            "title": "HTML5: Up and Running",
            "author": "Mark Pilgrim",
            "desc": "If you don't know about the new features available in HTML5, now's the time to find out. This book provides practical information about how and why the latest version of this markup language will significantly change the way you develop for the Web. HTML5: Up & Running carefully guides you though the important changes in this version with lots of hands-on examples, including markup, graphics, and screenshots. You'll learn how to use HTML5 markup to add video, offline capabilities, and more -- and youÕll be able to put that functionality to work right away.",
            "publishDate": "August 2010",
            "url": "http://oreilly.com/catalog/9780596806033/",
            "cover": [
                {
                    "type": "bigCover",
                    "source": "img/cat_noCover.gif",
                    "alternative": "HTML5 Up and Running"
                },
                {
                    "type": "cover",
                    "source": "img/bkt_noCover.gif"
                }
            ]
        }
    ]
}