1 Reply Latest reply on Aug 31, 2016 3:23 PM by Patrick A Van Der Hyde

    How to load js api from different servers for different environments of the same app

    Prateek Bajpayee



      I saw the tableau JS API integration :- http://onlinehelp.tableau.com/current/api/js_api/en-us/JavaScriptAPI/js_api.htm

      Tableau JavaSCript API


      It is specified there that include the JS file from your server tableau server as:-

      <script src="https://YOUR-SERVER/javascripts/api/tableau-2.js"></script>

      My problem is that for different environments of the same product I will have a different tableau server.


      So how can i include in the same html file different tableau server js urls.



      in my same home.html file i need to have:-


      for dev:- <script src="https://MY-DEV-SERVER/javascripts/api/tableau-2.js"></script>

      for prod:- <script src="https://MY-PROD-SERVER/javascripts/api/tableau-2.js"></script>



      I tried to append the js to the head after getting environment details but the js file is getting appended by not getting executed.


      $.getJSON('/app/resources/environments.json', function(data) {


          var sourcetab="My Tableau server URL";

          var script = document.createElement('script');

          script.type = 'text/javascript';

          script.src = sourcetab;




      Please provide a solution for this.


      Thanks in advance.