I am having an issue with call Drupal node.save using MooTool's JSONP. Here is an example.
Here is my request:
callback Request.JSONP.request_map.request_1
method node.save
sessid 123123123123123
node {"type":"blog","title":"New Title","body":"This is the blog body"}
Here is my result
HTTP/1.0 500 Internal Server Error
I got this working before, but i used AMFPHP and was able to send objects to drupal. I am assuming that this has to do with Drupal expecting an object, but since it is a GET it gets transformed as a string. Is there any way of getting around this with out hacking the code?
Here is my code:
$('newBlogSubmit').addEvent('click', function() { var node = { type : "blog", title:"New Title", body :"This is the blog body" } var string = JSON.encode(node); string.escapeRegExp() var sessID = _sessID; DrupalService.getInstance().node_save(string, sessID, drupal_handleBlogSubmit); });
My Drupal Service JS Code:
//NODE DrupalService.prototype.node_save = function(node, sessid, callback){ var dataObj = { method : "node.save", sessid : sessid, node : node } DrupalService.getInstance().request(dataObj, callback); } //SEND REQUEST AND CALLBACK FUNCTION DrupalService.prototype.request = function(dataObject, callback){ new JsonP('http://myDrupalSite.com/services/json', {data: dataObject,onComplete: callback}).request(); }
I am trying to connect the dots, but not too familiar with Drupal, but i would guess all I need to do is turn the string back into an object. Any ideas where I should be looking, or if there is an existing patch?