0

我在让 php echo 在 jQuery 中工作时遇到问题。

global $data; // fetch options stored in $data

你能指出我正确的方向吗,谢谢。

jQuery

$(window).load(function(){
  var slidertype = "<?php global $data; echo $data['slider_type']; ?>";
  $('.flexslider').flexslider( {
        animation: "slidertype",
        controlNav: false,
        smoothHeight: true, 
        slideshowSpeed: 7000, 
        animationSpeed: 600,
        start: function(slider) {
          $('body').removeClass('loading');
        }
      });
     });

PHP

<select id="slider_type" name="slider_type">
    <option value="slide" id="0"></option>
    <option value="fade" id="1"></option>
</select>
4

1 回答 1

3
$(window).load(function(){
  var slidertype = "<?php global $data; echo $data['slider_type']; ?>";
  $('.flexslider').flexslider( {
        animation: slidertype, // Need to reference the var, not a string literal
        controlNav: false,
        smoothHeight: true, 
        slideshowSpeed: 7000, 
        animationSpeed: 600,
        start: function(slider) {
          $('body').removeClass('loading');
        }
    });
 });
于 2013-01-30T23:14:30.210 回答