Drupal JSON POST from PhoneGap
Posted
by abritez
on Stack Overflow
See other posts from Stack Overflow
or by abritez
Published on 2009-11-24T16:41:43Z
Indexed on
2010/03/23
22:03 UTC
Read the original article
Hit count: 994
I am trying to send a POST request to Drupal's Services module & JSON_Server module, however I am getting
{ "#error": true, "#data": "Invalid method " }
Since PhoneGap runs html files from locally on the phone, should i need to worry about JSONP. The issue I have with that is that I must POST data, and JSONP only allows for GET. Any ideas would be helpful. Thanks!
//SEND REQUEST AND CALLBACK FUNCTION var req; DrupalService.prototype.request = function(dataObject, callback){ req = false; var url = DRUPAL_JSON_URL; var params = "data="+dataObject; try { req = new XMLHttpRequest(); } catch(e) { req = false; } if(req) { req.onreadystatechange = function() {//Call a function when the state changes. if(req.readyState == 4 && req.status == 200) { console.log(">> "+req.responseText); } } req.open("POST", url, false); req.send(params); } }
© Stack Overflow or respective owner