2012-04-18 23 views
0

jqueryスライダーを実装してウェブサイトのサポートページに証言を保存する小さなプロジェクトで作業します。人生を楽にするために、私は証言をXML文書に含めることを望んでいます。スライダーはページ上で正常に動作しますが、XML文書から証言テキストを取得するために関数を使用しようとすると、北朝鮮のロケットと同様に機能します。スライダのjqueryで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> 

は、私は別のスライダーを追加しますが、おそらくない、問題はdivitisで可能性がありますか?

だから、基本的に順序付けられたリストが移入されませんが、ここではxmlファイルはこれまでです:http://danielparmelee.com/testbed/crutchfield_test/:

<?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> 
+0

UPDATEを試してみてくださいsupport.htmlライブで見たときに動作しているように見えますが、李を空白のままにしておきます – danparm

+0

UPDATE2:http://danielparmelee.com/testbed/crutchfield_test/support.htmlスクリプトは私の感想のテキストをスライダに追加していますが、 – danparm

答えて

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(); 
      }) 
     } 
    });  
}); 
関連する問題