一部のデータを取得するために、salesforce データベースにクエリを実行しています。クエリ結果は、1 回の応答で最大 2000 レコードを返し、「nextRecordsUrl」パラメーターも返します。これを使用して、次の結果セットを取得できます。したがって、$.ajax() の done 関数で同じメソッドを再度呼び出すことで、これを実現できます。何か良い方法はないか知りたいです。
function stringSearch(queryParam){
var sessionCookie = getCookie('sid');
var currentDomain = window.location.host;
queryParam = queryParam== undefined || queryParam =='' ? "/services/data/v28.0/query/?q=SELECT+Name+from+Account" : queryParam;
$.ajax({
url : "https://"+currentDomain+queryParam,
headers : {"Authorization": "Bearer "+ sessionCookie},
contentType : "application/json"
}).done(function(res){
//do some processing with the result
processingFunction(res.records);
if(res.nextRecordsUrl){
//call the same method with different parameters
stringSearch(res.nextRecordsUrl);
}else{
//Done with all the processing proceed to final actions
}
}).fail(function(err){
alert('Oops!! We were unable to fetch the data you requested!\n'+JSON.stringify(err)+'\n ');
});
}
function processingFunction(){
//use the array and do some processing.
}