Demo entry 5862465

mypythoncode

   

Submitted by anonymous on Aug 04, 2016 at 22:28
Language: JavaScript. Code size: 1.3 kB.

      // creating a table is in principle similar to the process of inserting data
      // first the table is defined using plain JSON format
      // the string is pushed element by element into an array
      function createTable() {
        var tableResource = [];
        tableResource.push("{");
        tableResource.push("'name': 'Box Office Mojo',");
        tableResource.push("'columns': [");
        tableResource.push("{ 'name': 'Released', 'type': 'NUMBER' },");
        tableResource.push("{ 'name': 'Film Name', 'type': 'STRING' },");
        tableResource.push("{ 'name': 'Total Box Office', 'type': 'NUMBER' }");
        tableResource.push("],")
        tableResource.push("isExportable: true");
        tableResource.push("}");

        // the array is joined and send of to Fusion Tables API
        // while the request is handled within
        runClientRequest({
          path: '/fusiontables/v2/tables',
          body: tableResource.join(''),
          method: 'POST'
        }, function(resp) {
          var output = JSON.stringify(resp);
          document.getElementById('create-table-output').innerHTML = output;
          tableId = resp['tableId'];
          updateInsertSelectFields();
        });
      }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).