function test01(){ console.log("test"); var xhr = new XMLHttpRequest(); //&selectproperties='Title,Path,owstaxIdJiveCategories' xhr.open('GET', "https://mcn365.sharepoint.com/sites/a_IntranetPays_42/_api/search/query?querytext='owstaxIdJiveTags:GP0*+OR+owstaxIdJiveCategories:GP0*'&rowsperpage=0&rowlimit=5&selectproperties='Title%2cowstaxIdJiveCategories%2cowstaxIdJiveTags'&sortlist='Rank:descending%2cmodifiedby:ascending'&clienttype='ContentSearchRegular'"); xhr.setRequestHeader("Accept", "application/json; odata=verbose"); xhr.setRequestHeader("Connection", "close"); xhr.onload = function () { if (xhr.status === 200) { var kk = JSON.parse(xhr.responseText); /* console.dir(kk.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.length); console.dir(kk.d.query.PrimaryQueryResult); console.dir(kk.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results); */ var res = kk.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results; var Properties = kk.d.query.PrimaryQueryResult.RelevantResults.Properties; console.dir( kk.d); for(var i = 0 ; i < Properties.results.length ; i++){ console.log(Properties.results[i].Key + " || " + Properties.results[i].Value); } var tbl = ""; for(var i = 0 ; i < res.length ; i++){ console.dir(res[i]); tbl = tbl.concat(""); tbl = tbl.concat(""); tbl = tbl.concat(""); tbl = tbl.concat(""); for(var j = 0 ; j < res[i].Cells.results.length ;j++){ tbl = tbl.concat(""); tbl = tbl.concat(""); tbl = tbl.concat(""); tbl = tbl.concat(""); } } tbl = tbl.concat("
"); tbl = tbl.concat("Key"); tbl = tbl.concat(""); tbl = tbl.concat(""); tbl = tbl.concat(i); tbl = tbl.concat(""); tbl = tbl.concat("
"); console.log(res[i].Cells.results[j].Key); tbl = tbl.concat(res[i].Cells.results[j].Key); tbl = tbl.concat(""); console.log(res[i].Cells.results[j].Value); tbl = tbl.concat(res[i].Cells.results[j].Value); tbl = tbl.concat("
"); var tt = document.getElementById("spPageCanvasContent"); tt.innerHTML = tbl;console.log(tbl); } else { console.dir(xhr); alert('Request failed. Returned status of ' + xhr.status); } }; xhr.send(); } test01();