我们正在开发混合应用程序,此处从服务器获取数据。数据采用JSON格式,但从服务器加载数据需要15秒以上。
以下是示例代码:
$(document).ready(function(){
$("#cardetails").tap(function(event,ui){
$.ajax({
url:'http://wwwsampleurl.net/json/jsn_cmp.php?json=1&rcg_mobile=2&lan=en&callback=ajax_eup&pick_up_loc=AGPT01&drop_off_loc=AGPT01&country_des=ES&country_user=AE¤cy=EUR&day_drop=Tue&day_pick=Tue&age_driver=30&uid=0&num_days=7&pick_up=2722&drop_off=2722&pick_up_day=13&pick_up_hour=10&pick_up_minute=00&pick_up_mon=08&pick_up_year=2013&drop_off_day=20&drop_off_hour=10&drop_off_minute=00&drop_off_mon=08&drop_off_year=2013',
data:'',
contentType: "application/json; charset=utf-8",
type: "POST",
dataType: "json",
crossDomain:true,
cache: false,
async:false,
success: function(data, textStatus, jqXHR){
$.each(data, function(index, val) {
if(index=='gen'){
alert("gen data - "+val.pick_up_day);
}
else if(index=='company_date'){//alert('Load cars')
for (var i = 0, len = val.length; i < len; i++) {
//alert(JSON.stringify(val[i]));
// alert(val[i].car_img);
$('#carImages').append('<img src="'+val[i].car_img+'" width="70" height="110" alt="'+val[i].car_group+'" title="'+val[i].type+'"/>');
}
}
});
},
error: function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus +"-"+ errorThrown);}
});
});
});
任何人,请帮助改善表现......