-1

在这段代码中;$.get('sites.xml', function (d) {和它下面, $(d).find('site').each(function () {引用一个 xml 文件。我将如何引用一个 RSS 提要?

var $container = $('#container');
var $checkboxes = $('#filters a');

init();

function init(){
    $.get('sites.xml', function (d) {

        $(d).find('site').each(function () {
            var imageUrl = $(this).find('imgurl').text();
            var title = $(this).find('title').text();
            var url = $(this).find('url').text();
            var brief = $(this).find('brief').text();
            var long = $(this).find('long').text();
            var classa = $(this).find('_class').text();

            $('<div class="' + classa + '"></div>').html('<a href="' + url + '"> 
            <img  src="' + imageUrl + '" class="thumbnail" />' + '<h1>' + title + '</h1> 
            </a>').appendTo('#container');

            }); // end each

        initIsotop(); // after adding all elements - init isotop
    }); // end $.get
}

function initIsotop() {
    $container.isotope({
        itemSelector: '.item',
        transformsEnabled: false,    
        animationOptions: {
            duration: 4000,
            easing: 'easeInOutQuad',
            queue: false
        }
    });
}
4

1 回答 1

0

问题是如何将提要输入到代码中。对不起。我尝试使用的提要是一个 XML 文件。但我不确定如何将该 URL 包含到此代码中。

从您的代码:

$.get('sites.xml', function (d) {
       ^^^^^^^^^^
          Insert URI here.
于 2012-03-21T15:21:02.023 回答