I'm building an iPhone app using JQTouch/JQuery and PhoneGap, and so I was hoping the services module would allow me to pull content via javascript into my iPhone application from Drupal. In theory.
It took me all day to figure out why my calls weren't working with the normal JSON server...because it's cross-domain. Ugh.
So now I'm going to focus on JSONP, which should solve THAT problem. But I can't really find a clear explanation of how to do anything with key authentication in javascript. Or would key authentication even be necessary here? I do want it as secure as possible.
I already downloaded http://point-at-infinity.org/jssha256/ for the hash functions I need (I think I need anyway).
As a test, I want to try something like:
$.ajax({
type: "POST",
url: service_url,
dataType: "jsonp",
data: {"method": "node.get", "nid": 15},
success: function(msg){
alert( "Data: " + msg["#data"].nid );
}
});I assume this would work with authentication off, assuming I've made the proper modifications to the json_server module so it accepts jsonp. But what do I add to the data object if I am using key authentication with session ids?
Thanks!
Comments
solutions?
have you figured this out? I want to do the same thing.
I'm also interested in this
I'm also interested in this subject. Has anyone found a solution to this?
Reference
A solid reference is here: http://drupal.org/node/900630
JSONP connect
That reference link is for Drupal 6, and I'd like a Drupal 7 solution because services 3 supports JSONP.
I've been trying the following to connect and have had no luck. Any help would be much appreciated.
var val = {
type: "POST",
url: serviceEndpoint + "/system/connect.jsonp",
dataType: 'jsonp',
error: function(XMLHttpRequest, textStatus, errorThrown) {
jsonp can't post
This approach doesn't work.
I don't have an alternative for you, but when you attempt a POST request with JSONP it will be turned into a GET request. See http://stackoverflow.com/a/4508215/721065Here's an alternative: http://drupal.org/node/1334758