I'm trying to send inline parameters to a rest server:
jQuery.ajax({
type: "POST",
url: this.apiPath + '/disp',
dataType: 'json',
data: 'disp_id=' + disp_id,
success: callback
});
Is there a way to pass parameters to a jQuery ajax? I've tried in a lot of manners but no way...
data: {disp_id: disp_id},
data: "{disp_id:" + '"' + disp_id + '"}',
data: JSON.stringify({disp_id: disp_id}),
Always the same answer: "401 Unauthorized: Missing required argument disp_id".
The only way I achieved this is with:
jQuery.ajax({
type: "POST",
url: this.apiPath + '/disp?disp_id=' + disp_id,
dataType: 'json',
success: callback
});
Extra details:
this.apiPath = http://localhost/public_html/svc/disps
On the server side (drupal) I've defined the following hook_services_resources:
$services_resources['disps']['actions']['disp'] = array(
'help' => t('Retrieves the cue of objects for a given id'),
'file' => array('type' => 'inc', 'module' => 'disps', 'name' => 'resources/disps.resource', ),
'callback' => '_disps_resource_dispositivos',
'access callback' => 'disps_can_view_disp',
'access arguments' => array(NULL),
'access arguments append' => FALSE,
'args' => array(
array(
'name' => 'disp_id',
'type' => 'string',
'description' => '',
'source' => array('param' => 'disp_id', ),
'optional' => FALSE,
),
),
);