Q:

How to populate data from JSON using AJAX in TypeScript?

I have data attribute in my HTML page. I have a JSON file "rss.json". I am not getting the typescript code to call the JSON using AJAX.
<div class="js-rssfeed" data-url="rss.json"></div> //HTML

//TypeScript Code
 class RSSFeedManager {
 "use strict";

 private rootSelectionString: string = ".js-rssfeed";

 private $rootSelector: JQuery; 
constructor() {
     var base = this;
    base.$rootSelector = $(base.rootSelectionString);
    base.rssValidate();

}
private rssValidate() {
var base=this;
  if(base.$rootSelector.length!==0) {
        //getRssFeedJson();
    }
}   
}

var _RSSFeedManager = new RSSFeedManager();
export = _RSSFeedManager;

A:

using $.getJSON Jquery function you can load JSON data from the server using a GET HTTP request.
/////
     private rssValidate() {
        var base=this;
          if(base.$rootSelector.length!==0) {

                var jsonUrl = base.$rootSelector(base.$rootSelectionString).attr('data-url'); 
                $.getJSON(jsonUrl, function(data) {
                  console.log(data);
                });
            }
        }   
        }
///////

hope this help

