目前正在使用Angular和PHP进行项目,但问题是,我想在更新之前请求一些大量数据并对数据执行一些操作。我所做的是向PHP服务发出请求,一次将数据以200块的形式提供给我的javascript(Angular)。然后,我对数据执行操作并向PHP服务发出并发请求,并重复所有步骤直到所有数据都被整理出来,然后我最终请求更新在PHP服务的另一个请求中操作的所有数据。现在,我的问题是这种方法是否足够好还是有其他方法可以解决这个问题?
/**here is the PHP service block code to make request**/
<?php
function listApplicantByApplicationComplete(){
$dao=new DaoOperations();
$request=array('status'=>'APPLICATION_COMPLETE','programme_id'=>$_GET['programme_id'],'session_name'=>$_GET['session_name'],'session_id'=>$_GET['session_id']);
//print_r($request);
return $dao->listByLimit('user', $request,'&&',$_GET['page']);
}
?>
/**
*here is my js file receiving the data and performing operations on the data
* This is used to screen applicant in application complete
* @param programme
*/
vm.startScreening = function(programme, newStart) {
newStart = parseInt(newStart);
if (newStart == 0) resetScreenSaver();
console.log('newStart=' + newStart);
console.log('currentApplicantPage=' + currentApplicantPage);
vm.loader.hide = true;
vm.loader.msg = 'Screening Applicants, this may take some minutes, please wait...';
// if((!confirm('Are you sure you want to start screening process?'))) { return;}
vm.thisProgramme = angular.copy(programme);
var data = {
programme_id: vm.thisProgramme.id,
session_id: vm.session.id,
session_name: vm.session.name,
page: currentApplicantPage,
request: 'listApplicantByApplicationComplete'
};
ApiHandler.callService('POST', '../datastore/services/applicationProcessServices.php', data)
.then(function(resp) {
console.log('applicant=', resp.data);
if (resp.data != undefined && resp.data.status == 200) {
vm.applicantsToScreen = [];
vm.applicantsToScreen = resp.data.data;
if (resp.data.data != undefined && resp.data.data != 0 && resp.data.data.length > 0) {
currentApplicantPage += 1;
}
newStart++;
initializeScreening(); //calls the operations for data manipulation
} else {
newStart++;
if (vm.screen.pass.length > 0 || vm.screen.fail.length > 0) {
saveScreenedApplicants();
return;
}
vm.loader.hide = false;
Alert.error({
message: resp.data.message,
header: ''
});
}
}, function(err) {
vm.loader.hide = false;
console.log(err);
Alert.error({
message: 'Error encountered Screening Applicants',
header: ''
});
});
};