jQuery从xml加载图片

时间:2012-08-07 10:00:04

标签: jquery xml image flash prettyphoto

嗨我不想从xml加载图片并通过prettyphoto加载它这里是我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<images>

<image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image1.jpg"                

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image1.jpg"/>


<image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image2.jpg"                

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image2.jpg"/>

    <image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image3.jpg"        

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image3.jpg"/>

    <image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image4.jpg"        

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image4.jpg"/>

    <image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image5.jpg"        

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image5.jpg"/>

    <image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image6.jpg"        

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image6.jpg"/>

    <image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image7.jpg"        

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image7.jpg"/>

    <image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image8.jpg"        

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image8.jpg"/>

    <image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image9.jpg"        

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image9.jpg"/>

    <image source="Zdjecia/Galeria/Kategoria1/Miniaturki/image10.jpg"       

lightbox="Zdjecia/Galeria/Kategoria1/Duze/image10.jpg"/>
</images>

这是我的js函数:

jQuery(window).ready(function($) {
        $.get("XML/Kategoria1.xml",{},function(xml){
            $('image',xml).each(function(i) {
                lightbox = $(this).find("lightbox").text();
            });
        });



        $.fn.prettyPhoto();
        });


        function openLightbox(path) {

            $.prettyPhoto.open(lightbox);

            }

我要打开的第一张图片是它从闪存发送的“路径”和我要从xml加载的下一张图片“lightbox”但是这个脚本不起作用任何人都可以告诉我为什么或解释我该怎么做它??请求帮助。


这是我的html文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
    <head>
        <title>portfolio</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



<link rel="stylesheet" type="text/css" href="css/prettyPhoto.css" media="all"/>
     <script type="text/javascript" src="scripts/jquery-1.4.4.min.js"></script>
        <script type="text/javascript" src="scripts/jquery.prettyPhoto.js"></script>  
     <script type="text/javascript" src="scripts/swfobject.js"></script>
        <script type="text/javascript" src="scripts/swffit.js"></script>
        <script type="text/javascript">
            swfobject.embedSWF("portfolio.swf", "my_flash", "980", "640", "9.0.0", "", false, {wmode:'transparent'});
            swffit.fit("my_flash"); 

$(document).ready(function($) {
    $.get("xml/kategoria1.xml",{},function(xml){
    $('image',xml).each(function(i) {
        lightbox = $(this).find("lightbox").text();
        openLightbox(lightbox);
    });
});

function openLightbox(path) {
    $.prettyPhoto.open(path);
}
        </script>







        <style type="text/css" media="screen">
        html, body { height:100%; background-color: #000000;}
        body { margin:0; padding:0; overflow:hidden; }
        #flashContent { width:100%; height:100%; }
        </style>
    </head>
    <body>
        <div id="my_flash">
            <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="100%" id="portfolio" align="middle">
                <param name="movie" value="portfolio.swf" />
                <param name="quality" value="best" />
                <param name="bgcolor" value="#000000" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="transparent" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="lt" />
                <param name="allowScriptAccess" value="sameDomain" />
                <param name="allowFullScreen" value="true" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="portfolio.swf" width="100%" height="100%">
                    <param name="movie" value="portfolio.swf" />
                    <param name="quality" value="best" />
                    <param name="bgcolor" value="#000000" />
                    <param name="play" value="true" />
                    <param name="loop" value="true" />
                    <param name="wmode" value="transparent" />
                    <param name="scale" value="showall" />
                    <param name="menu" value="true" />
                    <param name="devicefont" value="false" />
                    <param name="salign" value="lt" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                <!--<![endif]-->
                    <a href="http://www.adobe.com/go/getflash">
                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Pobierz odtwarzacz Adobe Flash Player" />
                    </a>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
        </div>
    </body>
</html>

我尝试做一些事情并且这个脚本从xml加载单个图像,任何想法如何从xml加载所有“lightbox”图像

jQuery(window).ready(function($) {
    $.fn.prettyPhoto();
    $.get("xml/kategoria1.xml",{},function(xml){
    $('image',xml).each(function(i) {
        lightbox = $(this).find("lightbox").text();
      openLightbox(lightbox)
    });
});
});

function openLightbox(path) {
    $.prettyPhoto.open(path);

1 个答案:

答案 0 :(得分:0)

用上面的代码交换上面的代码......

$(document).ready(function($) {
    $.get("XML/Kategoria1.xml",{},function(xml){
    $('image',xml).each(function(i) {
        lightbox = $(this).find("lightbox").text();
        openLightbox(lightbox);
    });
});

function openLightbox(path) {
    $.prettyPhoto.open(path);
}