Rest API Call - Multiple SharePoint List
function GetListItems() {
function getJsonDataAsync(url) {
return $.ajax({
url: url,
method: "GET",
contentType: "application/json",
headers: {
accept: "application/json;odata=verbose"
}
});
}
var ListData1 = _spPageContextInfo.webServerRelativeUrl + "/_api/lists/GetByTitle('listname1')"
var ListData2 = _spPageContextInfo.webServerRelativeUrl + "/_api/lists/GetByTitle('listname2')"
var response1= getJsonDataAsync(ListData1);
var response2= getJsonDataAsync(ListData2);
jQuery.when(response1, response2).done(function(resp1, resp2) {
//do ur code here
});
}
function getJsonDataAsync(url) {
return $.ajax({
url: url,
method: "GET",
contentType: "application/json",
headers: {
accept: "application/json;odata=verbose"
}
});
}
var ListData1 = _spPageContextInfo.webServerRelativeUrl + "/_api/lists/GetByTitle('listname1')"
var ListData2 = _spPageContextInfo.webServerRelativeUrl + "/_api/lists/GetByTitle('listname2')"
var response1= getJsonDataAsync(ListData1);
var response2= getJsonDataAsync(ListData2);
jQuery.when(response1, response2).done(function(resp1, resp2) {
//do ur code here
});
}
Comments
Post a Comment