I need to display all the website from a given web application (sites.inside.ml) to users. Are the following steps correct?

  1. Create a page
  2. Drop a CEWP (content editor web part)
  3. Create a jQuery based code to bring back all the sites from a given web app with links to it.

Is there a better way?

  • seems perfect to me! Commented Jan 28, 2016 at 17:51
  • Is there any ready made jQuery for this so I am not re-inventing the wheel? Commented Jan 28, 2016 at 17:52
  • 2
    then you should ask for the ready made thing! Unfortunately it is not the right place of it! Commented Jan 28, 2016 at 17:55
  • use the content search web part. no need to write code then
    – Akhoy
    Commented Jan 29, 2016 at 6:30

1 Answer 1


You are in the right path. Use the search REST API. The below code from this post should get you started.

    <button id='btnGetSites'>Get Sites</button>

<div id='list'>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script type='text/javascript'>

    var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
    var url = siteUrl + "/_api/search/query?querytext='(contentclass:STS_Site OR contentclass:STS_Web)'";

            method: 'GET',
            url: url,
            dataType: 'json',
            success: success,
            error: error

        function success(data){
            var html = '';

            $.each(data.PrimaryQueryResult.RelevantResults.Table.Rows, function(index, row){                
                var title = '';
                var url = '';
                $.each(row.Cells, function(i, obj){             
                    if(obj.Key === 'Title'){
                        html += obj.Value; 
                    else if(obj.Key === 'Path'){
                        html += ": " + obj.Value + "<br/>";

        function error(err){
        return false;


  • This code is partial solution. It requires custom VS code. Commented Jan 28, 2016 at 19:25
  • For what purpose do you need custom VS code? Commented Jan 28, 2016 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.