admin管理员组文章数量:1026423
I need to write a PhoneGap application (with HTML5 and JS, I don't need patibility with IE) with AJAX so that it reads an RSS feed and looks up some specific information from it. The problem I'm having is that I have I don't the best way to do an RSS feed, and jQuery can't do XML. Any suggestions?
I need to write a PhoneGap application (with HTML5 and JS, I don't need patibility with IE) with AJAX so that it reads an RSS feed and looks up some specific information from it. The problem I'm having is that I have I don't the best way to do an RSS feed, and jQuery can't do XML. Any suggestions?
Share Improve this question asked Jun 26, 2011 at 12:12 Dhaivat PandyaDhaivat Pandya 6,5364 gold badges32 silver badges44 bronze badges5 Answers
Reset to default 5I recently made one using this tutorial : http://net.tutsplus./tutorials/javascript-ajax/how-to-build-an-rss-reader-with-jquery-mobile-2/
I have just made a phonegap application that parses an external RSS feed using jFeed. I'll give you an example:
First, I include the following Java scripts in my index.html file:
<head>
...
<script type="text/javascript" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" src="jquery/jquery-1.6.4.js"></script>
<script type="text/javascript" src="jquery.mobile/jquery.mobile-1.0b3.min.js"></script>
<script type="text/javascript" src="jquery.jfeed/dist/jquery.jfeed.js"></script>
<script type="text/javascript" src="scripts/my.js"></script>
...
</head>
Then, in my.js
I use the following:
parseFeed();
function parseFeed() {
$.getFeed({
url: 'http://someUrl.',
dataType: "xml",
success: function(feed) {
$('#feedresult').empty();
var html = '<ul data-role="listview">';
for(var i = 0; i < feed.items.length; i++) {
var item = feed.items[i];
html += '<li>'
+ '<a href="#article?id='
+ i
+ '">'
+ item.title
+ '</a>'
+ '</li>';
}
html = html + '</ul>';
$('#feedresult').append(html);
$('#main').page('destroy').page();
}});
};
The code then creates a listview (jQuery mobile) in my #feedresult div where each entry represents a feed item. As phonegap utilizes some sort of web view that loads all content using the file:/// protocol ( http://groups.google./group/phonegap/browse_thread/thread/b60bda03bac6e9eb ), there is no issue in doing cross domain XMLHttpRequest from phonegap.
This question is old, but can be helpful to solve it in 2014 ;-).
I test many jQuery plugin to include a RSS reader, but the only this work like a charme in 1mn is zrssfeed
Just add the call (after call jquery and jquery mobile) in the header:
<script type="text/javascript" src="jquery.zrssfeed.min.js"></script>
And after start th jquery call like this :
<script type="text/javascript">
$(document).ready(function () {
$('#feedresult').rssfeed('http://my.wordpress.website./feed/', {
limit: 5
});
});
</script>
I hope this help, Mike
What You mean jQuery can't do XML. jQuery is JavaScript and jQuery uses XMLHttpRequest
while doing Ajax calls. See the name XML*
. See: http://api.jquery./jQuery.ajax/. There is dataType
param. You can pass xml
to it. After that You will get dom object with all dom object methods.
You can event use it as second param to jQuery's selectors:
jQuery.get(url, {}, function (data) {
var entries = $("entry", data);
doSomething(entries);
}, 'xml');
One option would be to use a RSS-to-JSON pipe, like this one here: http://pipes.yahoo./pipes/pipe.info?_id=2FV68p9G3BGVbc7IdLq02Q
I need to write a PhoneGap application (with HTML5 and JS, I don't need patibility with IE) with AJAX so that it reads an RSS feed and looks up some specific information from it. The problem I'm having is that I have I don't the best way to do an RSS feed, and jQuery can't do XML. Any suggestions?
I need to write a PhoneGap application (with HTML5 and JS, I don't need patibility with IE) with AJAX so that it reads an RSS feed and looks up some specific information from it. The problem I'm having is that I have I don't the best way to do an RSS feed, and jQuery can't do XML. Any suggestions?
Share Improve this question asked Jun 26, 2011 at 12:12 Dhaivat PandyaDhaivat Pandya 6,5364 gold badges32 silver badges44 bronze badges5 Answers
Reset to default 5I recently made one using this tutorial : http://net.tutsplus./tutorials/javascript-ajax/how-to-build-an-rss-reader-with-jquery-mobile-2/
I have just made a phonegap application that parses an external RSS feed using jFeed. I'll give you an example:
First, I include the following Java scripts in my index.html file:
<head>
...
<script type="text/javascript" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" src="jquery/jquery-1.6.4.js"></script>
<script type="text/javascript" src="jquery.mobile/jquery.mobile-1.0b3.min.js"></script>
<script type="text/javascript" src="jquery.jfeed/dist/jquery.jfeed.js"></script>
<script type="text/javascript" src="scripts/my.js"></script>
...
</head>
Then, in my.js
I use the following:
parseFeed();
function parseFeed() {
$.getFeed({
url: 'http://someUrl.',
dataType: "xml",
success: function(feed) {
$('#feedresult').empty();
var html = '<ul data-role="listview">';
for(var i = 0; i < feed.items.length; i++) {
var item = feed.items[i];
html += '<li>'
+ '<a href="#article?id='
+ i
+ '">'
+ item.title
+ '</a>'
+ '</li>';
}
html = html + '</ul>';
$('#feedresult').append(html);
$('#main').page('destroy').page();
}});
};
The code then creates a listview (jQuery mobile) in my #feedresult div where each entry represents a feed item. As phonegap utilizes some sort of web view that loads all content using the file:/// protocol ( http://groups.google./group/phonegap/browse_thread/thread/b60bda03bac6e9eb ), there is no issue in doing cross domain XMLHttpRequest from phonegap.
This question is old, but can be helpful to solve it in 2014 ;-).
I test many jQuery plugin to include a RSS reader, but the only this work like a charme in 1mn is zrssfeed
Just add the call (after call jquery and jquery mobile) in the header:
<script type="text/javascript" src="jquery.zrssfeed.min.js"></script>
And after start th jquery call like this :
<script type="text/javascript">
$(document).ready(function () {
$('#feedresult').rssfeed('http://my.wordpress.website./feed/', {
limit: 5
});
});
</script>
I hope this help, Mike
What You mean jQuery can't do XML. jQuery is JavaScript and jQuery uses XMLHttpRequest
while doing Ajax calls. See the name XML*
. See: http://api.jquery./jQuery.ajax/. There is dataType
param. You can pass xml
to it. After that You will get dom object with all dom object methods.
You can event use it as second param to jQuery's selectors:
jQuery.get(url, {}, function (data) {
var entries = $("entry", data);
doSomething(entries);
}, 'xml');
One option would be to use a RSS-to-JSON pipe, like this one here: http://pipes.yahoo./pipes/pipe.info?_id=2FV68p9G3BGVbc7IdLq02Q
本文标签: jqueryPhonegap RSS feedsJavaScriptStack Overflow
版权声明:本文标题:jquery - Phonegap RSS feeds, Javascript - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1740049985a1709760.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论