上点击刷新XML饲料(jQTouch)
-
26-09-2019 - |
题
我最近创建的XML饲料 - > HTML的JavaScript功能的iPhone应用程序,我在jQTouch发展。 原始一>教程和代码。
我想知道是否有人会知道一个快速简便的方法来刷新XML数据(再次抢进)点击一个链接时。
例如。 的中的代码:强>
<div id="btns">
<ul>
<li><a href="#feed">Go to feed</a></li> <!-- When i click this, I want the getDataFeed function to dump the data & rerun. -->
</div>
<div id="feed">
<div id="content_from_feed_inserted_here"></div>
</div>
<强>在JavaScript:强>
$(document).ready(function() {
function getDataFeed() {
$('.loadingPic').show(); // show progress bar
$.get('http://xxxxxxx.com/information.xml', function(d) {
$(d).find('location').each(function(){
var $location = $(this);
var the_data = $location.find('xml_data').text();
var collected_data = collected_data += '<span>' + the_data + '</span>' ;
$('#content_from_feed_inserted_here').empty().append($(collected_data)); // empty div first
$('.loadingPic').fadeOut(1400); // remove progress bar
});
}
// run on page load
getDataFeed();
// how do i also get it running when i click <li><a href="#feed">Go to feed</a></li>
});
在预先感谢您的帮助!
解决方案
测试此:
移动功能getDataFeed(){..}外面去从链接功能齐全和捕获点击事件。在<a>
组ID = “进料”。
function getDataFeed() {
$('.loadingPic').show(); // show progress bar
$.get('http://xxxxxxx.com/information.xml', function(d) {
$(d).find('location').each(function(){
var $location = $(this);
var the_data = $location.find('xml_data').text();
var collected_data = collected_data += '<span>' + the_data + '</span>' ;
$('#content_from_feed_inserted_here').empty().append($(collected_data)); // empty div first
$('.loadingPic').fadeOut(1400); // remove progress bar
});
}
$(document).ready(function() {
// how do i also get it running when i click <li><a href="#feed" id="#feed">Go to feed</a></li>
$('#feed').click(getDataFeed);
// run on page load
getDataFeed();
});
不隶属于 StackOverflow