0

我只想在 HTML<script>标记中添加下面提到的 JavaScript。

但下面提到的 CakePHP 3.8scriptBlock函数并没有在我的 HTML 页面上创建任何元素。

echo $this->Html->scriptBlock('
    $.get("/feed.rss", function(data) {
        var $XML = $(data);
        var active=" active";
        $XML.find("item").each(function() {
            var $this = $(this),
                item = {
                    title:       $this.find("title").text(),
                    link:        $this.find("link").text(),
                    description: $this.find("description").text(),
                    pubDate:     $this.find("pubDate").text(),
                    author:      $this.find("author").text()
                };
            $(".carousel-inner").append("<div class=\"carousel-item" + active + "\"><h2>" + item.title + "</h2>" + item.description + "</div>");
            active = "";
        });
    });
    $(".carousel").carousel();',
    
    ['buffer' => true]
);

请告诉我我该怎么办?

4

0 回答 0