使用ajax/jquery解析wordpress RSS提要

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用ajax/jquery解析wordpress RSS提要相关的知识,希望对你有一定的参考价值。

* Set your local path to the wordpress install, in my case was: "/blog/feed"
* Edit the var contain = make it set to the selector, in my case I'm populated a list tag <ul></ul>.
* Edit the var limit = 5; Set the amount of blog posts you want to display.
  1. $.ajax({
  2. type: "GET",
  3. url: "/blog/feed",
  4. dataType: "xml",
  5. success: function(xml) {
  6.  
  7. var contain = $("div.panel ul");
  8. var limit = 5;
  9.  
  10. $(xml).find('item').each(function(index){
  11. if( index < limit ){
  12. var title = $(this).find('title').text();
  13. var url = $(this).find('link').text();
  14. var pubDate = $(this).find('pubDate').text();
  15. $('<li></li>').html('<a href="'+url+'">'+title+'</a>').appendTo(contain);
  16. return;
  17. }
  18.  
  19. });//end each
  20. }
  21. });

以上是关于使用ajax/jquery解析wordpress RSS提要的主要内容,如果未能解决你的问题,请参考以下文章

05 ajax,jquery,xstream,json解析

尝试在页面滚动上加载帖子时出现 Ajax/Jquery/PHP 问题

jQuery 源码解析 异步队列模块 Callbacks 回调函数详解

使用Ajax Jquery和asmx服务获取Id的数据

我啥时候使用 PHP_EOL 而不是 \n ,反之亦然? Ajax/Jquery 客户端问题

如何使用 Python 解析 WordPress CSV 导出