title: Pass JSON to JQuery function Javascript
body: <p>We have a very simpel Google Apps Script Web App, which purpose is to show JSON data in a HTML drop-down-list. The JSON file exists in Google Drive. Inspiration code from: <a href="http://jsfiddle.net/manoj_admlab/Mta5b/3/" rel="nofollow noreferrer">http://jsfiddle.net/manoj_admlab/Mta5b/3/</a></p>
  
  <p>But when we are trying to 'Fetch Json' no data is loaded in to the dropdown-list:
  <a href="https://i.stack.imgur.com/YxzoO.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YxzoO.gif" alt="enter image description here"></a></p>
  
  <h1><strong>index.html</strong></h1>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;br&gt; &lt;br&gt;
      &lt;center&gt;
      &lt;head&gt;
      &lt;base target="_top"&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
  
      &lt;select id="destinations"&gt;
      &lt;option value=""&gt;Select&lt;/option&gt;
      &lt;/select&gt;
      &lt;a href="#" id="fetch"&gt;Fetch JSON&lt;/a&gt;
      &lt;/center&gt;
  
  
      &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt; &lt;/script&gt;
      &lt;script&gt;
      google.script.run.getJson(); // Runs the function "getJson();" in Code.gs
  
      $('#fetch').click(function(s) {
  
          $.post(s, {json: JSON.stringify(json)}, function(data) {
              $.each(data.Destinations, function(i, v) {
                  $('#destinations').append('&lt;option value="' + v.destinationID + '"&gt;' + v.destinationName + '&lt;/option&gt;');
              });
          });
      });
  
      &lt;/script&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <h1><strong>Code.gs</strong></h1>
  
  <pre><code>function doGet() {
        var template = HtmlService.createTemplateFromFile('index');
  
        var htmlOutput = template.evaluate()
                         .setSandboxMode(HtmlService.SandboxMode.NATIVE);
  
        return htmlOutput;
      }
  
      function getJson() {
  
      var files = DriveApp.getFilesByName("jsonData.json");
        var file = files.next();
        var JSONDATA = file.getAs("application/json").getDataAsString();
        //JSONDATA = JSON.stringify(JSONDATA);
        JSONDATA = JSON.parse(JSONDATA);
        Logger.log(JSONDATA);
  
      click(JSONDATA); // &lt;-- Trying to pass this data to "$('#fetch').click(function(s) {"
      }
  </code></pre>
  
  <h1><strong>jsonData.json</strong></h1>
  
  <pre><code>{
          "options": {    
             "Destinations": [
          {
              "destinationName": "London",
              "destinationID": "lon"
          },
          {
              "destinationName": "New York",
              "destinationID": "nyc"
          },
          {
              "destinationName": "Paris",
              "destinationID": "par"
          },
          {
              "destinationName": "Rome",
              "destinationID": "rom"
          }
          ]
      }
      }
  </code></pre>