0

jquery スライダーを実装して、Web サイトのサポート ページに証言を保持する小さなプロジェクトに取り組んでいます。生活を楽にするために、証言を XML ドキュメントに含めたいと考えています。スライダーはページ上で正常に動作しますが、関数を使用して XML ドキュメントから証言テキストを取得しようとすると、北朝鮮のロケットと同じように動作します。

のスクリプト:

<head>
<title>Crutchfield Customer Support - Online Support Center</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="support.css" />

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js" type="text/javascript"></script>

<script src="slider/jquery.bxSlider.min.js" type="text/javascript"></script>

<script type="text/javascript">
  $(document).ready(function(){
    $('#slider1').bxSlider({
    auto: true,
    autoControls: false,
    nextText: '',
    prevText: ''
    });
  });
</script>

<script type="text/javascript">
$(document).ready(function(){
    $.ajax({
        type: "GET",
        url: "testimonials.xml",
        dataType: "xml",
        success: function(xml) {
            var select = $('#slider1');
            $(xml).find('testimonials').each(function(){
                var text = $(this).find('text').text();
                select.append("<li class='test'>"+text+"</li>");
            });
        }
    });
});
</script>

</head>

スライダーの HTML:

    <div id="testimonials">
        <div class="testimonialGroupOne">
            <ul id="slider1">
                <li>loading</li>
            </ul>
        </div>
    </div>

別のスライダーを追加するかもしれませんが、おそらく追加しないでしょう。問題は分割にあるのでしょうか?

したがって、基本的に順序付きリストは入力されません。これまでの xml ファイルは次のとおりです。

<?xml version="1.0" encoding="ISO-8859-1"?>
<testimonials>
    <text>"I have been doing business with Crutchfield for over fifteen years and have yet to have a negative experience. Their customer service is second to none."</text>
    <text>"I've been a Crutchfield customer for over 20 years. I've found their customer service and technical support to surpass every other vendor in this business. Without exception, every contact I've had with Crutchfield employees, I have found them to be professional, competent, respectful and patient."</text>
</testimonials>
4

1 に答える 1

1

これを試して

var mySlider;
    $(document).ready(function () {
        $.ajax({
            type: "GET",
            url: "data/yourxml.xml",
            dataType: "xml",
            success: function (xml) {


            $(xml).find('testimonials').each(function(){

                xml_name = $(this).find('name').text();

                $('#slide').append('<li>' + xml_name + '</li>')
            });

            $(function () {
                mySlider = $('#slide').bxSlider({
                    auto: true,
                    controls: false
                });

                mySlider.reloadShow();
            })
        }
    });    
});
于 2012-07-02T16:12:59.767 に答える