Hi. Following the latest suggestion on #831, I have installed Services Contact module and I create my own form to send contact messages. This is my submit function:
function mymodule_mycontact_form_submit(form, form_state) {
try {
var myformdata = {
name: form_state.values['name'],
mail: form_state.values['email'],
subject: form_state.values['subject'],
message: form_state.values['message'],
cid: 1
};
Drupal.services.call({
method: 'POST',
path: 'contact/site',
data: myformdata,
contentType: 'application/json',
success: function(result) {
console.log(result);
var msg = 'Your message has been sent.';
drupalgap_alert(msg);
},
error: function(result) {
console.log(result);
var msg = 'Error sending your message';
drupalgap_alert(msg);
}
});
}
catch (error) { console.log('mymodule_mycontact_form_submit - ' + error); }
}
The problem is I always get POST erro - 400 - : Invalid JSON. I tried the same json with Chrome Rest Client and It works good. I don't know why I get this error. Is there a mistake on the array or the options?
Hi. Following the latest suggestion on #831, I have installed Services Contact module and I create my own form to send contact messages. This is my submit function:
The problem is I always get POST erro - 400 - : Invalid JSON. I tried the same json with Chrome Rest Client and It works good. I don't know why I get this error. Is there a mistake on the array or the options?