0

我在使用 JQM 更新列表时遇到问题。我有 2 个页面,index.html 和一个详细信息页面。在第一页上,我使用 Ajax 从远程 .php 文件中获取结果。一切都在这里顺利进行。在此页面上,我还有:

<a href="plumberdetails.html" data-transition="pop" > . . . </a>

重定向到第二页时,列表未正确更新。我还不得不说,第二页上的信息是从远程 .php 文件中填充的。但是如果我刷新第二页,信息就会完美填充。我注意到进入data-rel = external第一页就可以了。我不想用这个,因为我将不再有 2 页之间的过渡效果。我也尝试过$('#ul_ID').listview('refresh');$('#ul_ID').trigger('create');在 Ajax 请求中,但仍然无法使其工作。

如果您能帮助我,我将不胜感激。谢谢,

第 1 页的外部 .js:

    $.ajax({
    url: URL + 'getplumbers.php',
    dataType: 'jsonp',
    jsonp: 'jsoncallback',
    timeout: 5000,
    success: function(data, status){
        $.each(data, function(i,item){ 
            $('#output').append('<li><a href="plumberdetails.html">' +
                '<h4 style="color:#DC143C">' + item.name + '</h4>' +
                '<p style="color:#6B8E23">' + item.address + '</p>' +
                '<span class="ui-li-count">' + item.city + '</span></a></li>');
            $('#output').listview('refresh');
        });
    },
    error: function(){
       output.text('There was an error loading the data.');
    }
});

第二页的 .js 看起来像这样:

    $.ajax({
    url: 'http://plumberin.cu.cc/services/getplumber.php',
    dataType: 'jsonp',
    jsonp: 'jsoncallback',
    timeout: 5000,      
    success: function(data, status){
            $('#output2').append('<li><h4 style="color:#DC143C">' + data.name + '</h4>' +
                '<p style="color:#6B8E23">' + data.address + '</p>' +
                '<span class="ui-li-count">' + data.city + '</span></a></li>')
            $('#output2').listview('refresh');

    },
    error: function(){
       output.text('There was an error loading the data.');
    }
});
4

0 回答 0