JavaScript examples

103 views
Skip to first unread message

Orchid1

unread,
Apr 19, 2010, 5:07:57 PM4/19/10
to Snooth API
hello can anyone pint me to some sample documentation for handling a
store query

EXAMPLE:
api.snooth.com/wines/q=something+somethin+something

I cant seem to be able to handle the response properly with JavaScript

Thanks for the API I'm loving working with it. you have pretty good
documentation on the site but I think I just need a few more examples
of handling responses.


--
You received this message because you are subscribed to the Google Groups "Snooth API" group.
To post to this group, send email to snoot...@googlegroups.com.
To unsubscribe from this group, send email to snooth-api+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/snooth-api?hl=en.

mark angelillo

unread,
Apr 19, 2010, 6:02:48 PM4/19/10
to Snooth API
Hi Orchid,

The best way to handle data from the API in Javascript is to request
JSON from the API. If you get JSON, then you will not need to worry
about parsing XML.

You can read more about JSON here: http://www.json.org/

JSON is easy to use. Let's say I have a JSON object that looks like
this:

var winedata = { name: 'Test Wine 1', vintage: '2001' };

I can easily access the data.

alert('Alerting wine ' + winedata.name + ' ' + winedata.vintage);

Hope that helps.

Mark

Orchid1

unread,
Apr 19, 2010, 7:38:59 PM4/19/10
to Snooth API
that helps thank you the only problem I guess is how do I add the
callback tot he request
I am trying this :

EXAMPLE:
api.snooth.com/wines/?akey=XXXXXXXXXXXXX&q=viader
+vineyards&callback=handleResult

handleResults(winedata)
{
alert('Alerting wine ' + winedata.name + ' ' +
winedata.vintage);
}

the assumption I am making is the callback parameter. I'm assuming it
is called "callback"


thank you again for the response

Orchid1

unread,
Apr 19, 2010, 8:21:04 PM4/19/10
to Snooth API
I'm going to try handling the JSON with PHP
but I am still curious if there is a way of setting a Javascript
callback through a parameter in the request like
'&callback=myCallback'


:) cheers

Orchid1

unread,
Apr 19, 2010, 9:32:44 PM4/19/10
to Snooth API
Thanks for the link It helped.
I am working with PHP now to get the data rather than using a
callback.
got it working.
Im super excited :D !
Reply all
Reply to author
Forward
0 new messages