问了好多人,都说取不到数据是因为跨域了,为什么会跨域呢?
(function($) {
//阻尼系数
var deceleration = mui.os.ios?0.003:0.0009;
$(‘.mui-scroll-wrapper’).scroll({
bounce: false,
indicators: true, //是否显示滚动条
deceleration:deceleration
});
$.ready(function() {
//循环初始化所有下拉刷新,上拉加载。
$.each(document.querySelectorAll(‘.mui-slider-group .mui-scroll’), function(index, pullRefreshEl) {
$(pullRefreshEl).pullToRefresh({
down: {
callback: function() {
var self = this;
setTimeout(function() {
var ul = self.element.querySelector(‘.mui-table-view’);
ul.insertBefore(createFragment(ul, index, 10, true), ul.firstChild);
self.endPullDownToRefresh();
}, 1000);
}
},
up: {
callback: function() {
var self = this;
var arr = {
callback: getAjaxData
};
setTimeout(function() {
var ul = self.element.querySelector(‘.mui-table-view’);
ul.appendChild(createFragment(ul, index, 5, arr));
self.endPullUpToRefresh();
}, 1000);
}
}
});
});
var dataArr = [];
var getAjaxData = function(){
var url = ‘http://www.beta.anviz.com/myanviz/faq/ajax.html?category_id=0’;
mui.ajax({
type: ‘GET’,
url: url,
dataType: ‘json’,
success: function(data) {
console.log(data);
var list = data.data;
for(var i = 0; i < list.length; i++) {
console.log(‘list’ + list);
var item = list[i];
var faqName = item.faqName;
var faqId = item.faqId;
var dataEntity = {};
dataEntity.faqName = faqName;
dataEntity.faqId = faqId;
dataArr.push(dataEntity);
}
return dataArr;
}
});
}
var createFragment = function(ul, index, count, reverse) {
var fragment = document.createDocumentFragment();
var li;
var arr = reverse;
for (var a = 0; a < count; a++) {
li = document.createElement(‘li’);
li.className = ‘mui-table-view-cell’;
li.innerHTML = ‘
fragment.appendChild(li);
}
return fragment;
};
});
})(mui);