New to Services Looking for little help

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by gbernier on June 1, 2010 at 8:42pm

Hey All,

Update 1: I've tried using all the other servers I've got installed, AMFPHP and XMLRPC and I get nothing back as well. I did this just to see if maybe it was the json server. The message I'm getting from JSON is the same one I get when you go to /services/json from the browser.


Like the title says I'm new to services and not having the smoothest entrance into this world. Building the service was a straight forward and had my very own services up and running in no time. Where I'm having a struggle is getting access to these services through JavaScript.

I've seen this article, http://drupal.org/node/305819, which says to use Drupal.service() but it's not clear where you should be calling the json_load to include the appropriate JavaScript files. I've tried using jQuery's .ajax and getJSON as well but keep getting the error back saying "#data:" "Invalid Method"

$.ajax({
url: "/services/json",
dataType: "text",
data: {"method": "car_service.get_product_listing", "tids": "28"},
success: alertMe,
});

function alertMe(response){
alert(response);
}

Is there a resource I've missed somewhere along my journey's which will help me out or give me a good point in the right direction.

Cheers,
Gene Bernier

Comments

Got it Working

Posted by gbernier on June 2, 2010 at 10:25pm

Hey,

Incase anyone else comes along trying to do what I did using jQuery here's a few things you need to know.

  1. After looking at the code in the JSON server it ends up you have submit all requests as POSt
  2. arguments in the data: need to be passed same as it would be on a query string

Here's the code I'm using and it is work, my service method returns a string of html to me


$.ajax({
type: "POST",
url: "http://carccessory.acro.dev/services/json",
dataType: "json",
data: "method=car_service.get_product_listing&tids=28",
success: populateProductListing,
});

function populateProductListing(response){
if(!response['#error']){
$("#productListingContainer").html(response['#data']);
}
}

Hope this saves someone else a few minutes of frustration

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /