我有我想一次加载一个函数的列表。我无法让它们加载一个,然后在加载数据后再转到下一个。这里是我的代码:用jQuery一次加载一个函数?
$(document).ready(function() {
//step through the data sets
var count = 1;
if (count = 1) {
loadingAjax('connectConferenceData','connectAttendanceData',count);
}
if (count = 2) {
loadingAjax('connectWorkshopData','cwsData',count);
}
if (count = 3) {
loadingAjax('relayCenterData','rcData',count);
}
if (count = 4) {
loadingAjax('collectionCenterData','ccData',count);
}
if (count = 5) {
loadingAjax('regionalStatsData','rsData',count);
}
if (count > 5) {
$("#statusMsg").html('All tools have been loaded.').fadeIn('slow');
setTimeout(function() {
$('#statusMsg').fadeOut();
}, 10000);
}
});
//function to get datasets
function loadingAjax(div_id,action_id,count) {
$("#loading").show();
$("#"+div_id).html('<img src="images/admin_uploading.gif"> Loading data...');
$.ajaxSetup ({
cache: true
});
$.ajax({
type: "GET",
url: "dashboard_functions.php",
data: "actionID="+action_id,
success: function(data){
$("#"+div_id).html(data).fadeIn();
count++;
if (count != 6) {
$("#statusMsg").html('<img src="./images/admin_uploading.gif" /> Loading data for tool #'+count+' loading');
}
$("#loading").hide();
}
});
}
上先看看你需要使用“==”而不是在所有if语句中使用'=' –
甚至===强制没有类型强制,或者只是删除它,并把正确的调用放在你的成功处理程序 – NimChimpsky