// SAMPLE AJAX FUNCTION
// $table_name - required - name of table to be queried
// $id - optional - id of individual record to be returned
// $params - optional - request parameters that will be formatted for url
function makeCall($service_name, $table_name, $id, $params) {
// Did we pass a service name
if (!$service_name) return false;
// Did we pass a table name
$table_name = $table_name || '';
// Did we pass in params - if not set to empty object
$params = $params || {};
// Did we specify a record id. If not set to empty string
$id = $id || '';
// Make ajax call
return $.ajax({
dataType: 'json',
url: '/rest/remote_local/' + $table_name + '/' + $id + '?' + $.param($params),
type: 'GET',
headers: {
'X-DreamFactory-Application-Name': 'admin'
}
})
}
// SAMPLE USAGE
// Use a real service and table name on your DSP
var serviceName = ENTER_SERVICE_NAME_HERE;
var tableName = ENTER_TABLE_NAME_HERE;
// Sample of passing a request param
var requestParams = {
limit: 2
}
makeCall(serviceName, tableName, '', requestParams).done(function(data) {console.log(data)});