We do this with our WDC. Essentially, we use the WDC to present data available via an API as tables and columns in tableau. We require authentication, which gives the user associated roles and privileges. Based on those roles and privileges, the data the is presented via the API can vary dramatically.
The connector.getSchema function in our WDC calls our API to retrieve the set of tables (and what columns are in them) based on your user context. It issues an XHR (XMLHttpRequest, although you could use an ajax call as well) and in the `onload` callback takes the results of the REST call and formulates the required table schema before calling `schemaCallback`.
The connector.getData function performs very similarly. It takes the table name (as constructed for the getSchema function) and makes another XHR REST call to our server to respond with the proper data for that table (again, filtered based on the user context). In the `onload` callback of the XMLHttpRequest, it constructs each row and calls table.appendRows, before calling the doneCallback() when it is complete.
Really the only "trick" is the the schema retrieval call in our REST API has to return table names that it can recognize in the data retrieval call later. Otherwise, it's all pretty straightforward. The reason for the schemaCallback and doneCallback functions is so you can perform asynchronous calls (in our case REST calls) in your WDC.