我必须通过ajax调用在jquery mobile中的模板中附加数据,并且我正在使用以下库和listview函数来引用现有的listview(“refresh”)函数,但它显示js错误,即listview不是函数,而函数存在于下面的库:
<script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script>
<script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script src="https://d10ajoocuyu32n.cloudfront.net/codiqa.ext.js"></script>
这是我用过的
jQuery(document).ready(function () {
jQuery('.pagination_ajax_request').click(function () {
jQuery.ajax({
type: 'POST',
url: this.href,
dataType: 'html',
data: 'pagination_ajax_request=1',
success: function (response) {
// check if <div id="pagination"><div> exist, means ajax resopnse from post listing page other wise ajax resopnse from topic listing page
if (jQuery("#pagination").length) {
jQuery("#pagination").append(response);
} else {
jQuery("#topic_list").append(response);
jQuery("#topic_list").listview("refresh");
}
if (ajax_pagination_data['current_page'] != ajax_pagination_data['total_pages'] && ajax_pagination_data['current_page'] != '0') {
//update "Load More Topics" OR "Load More Posts" link href value
var href = jQuery(".pagination_ajax_request").attr('href');
jQuery(".pagination_ajax_request").attr('href', href.replace(/&?trail=\d+/, '&trail=' + ajax_pagination_data['trail']));
} else {
//hide "Load More Topics" OR "Load More Posts" if No topic OR post
jQuery(".pagination_ajax_request").hide();
}
},
error: function (xhr, textStatus, errorThrown) {
alert('An error occurred while processing your request.\n' + textStatus + ': ' + errorThrown);
}
});
return false;
});
});