I see the problem now.
You should not return myHandler(...), unless this name was specified in the
responseHandler parameter in the request.
Please see more at:
http://code.google.com/apis/visualization/documentation/dev/implementing_data_source.html#responseformat
If it wasn't specified, you should return:
google.visualization.Query.setResponse({status:ok, ...})
Which will in turn call your handler automatically.
This is a static function that gets all of the responses, and dispatches
them to the correct handlers (myHandler, in your case).
VizGuy
On Wed, Nov 19, 2008 at 10:46 AM, bgoetzmann <[EMAIL PROTECTED]>wrote:
>
> This is because I see that when send(null) is executed, my myHandler
> JavaScript function is automatically executed!
> This function is defined in my web page, and the URL I use returns the
> string:
> myHandler({"version":"0.5","reqId":"1","status":"ok","table":{"cols":
> [... )
>
> So my initial question was: is it normal?
>
> Bertrand ;-)
>
>
>
> On 18 nov, 22:04, VizGuy <[EMAIL PROTECTED]> wrote:
> > The right thing to d ois to pass the name of the response handler
> function
> > to be called as the parameter to the send function:query.send(myHandler);
> > and not query.send(null).
> >
> > I failed to understand why you initially called it with null, is this
> just a
> > mistake, or is there any reason for this?
> >
> > VizGuy
> >
> > On Tue, Nov 18, 2008 at 2:40 PM, bgoetzmann <[EMAIL PROTECTED]
> >wrote:
> >
> >
> >
> >
> >
> > > Finally it works, but with an other way!
> >
> > > Instead to use query and call:
> >
> > > query.send(null);
> >
> > > I can use a Grails tag that permits to call an action via AJAX (with
> > > the Prototype library): here the code (the tag is uses in its function
> > > form):
> >
> > > function initialize() {
> > > ${remoteFunction(action: 'data', onSuccess: 'fOnSuccess(e);')}
> > > }
> >
> > > If the AJAX call succeeded, the fOnSuccess JavaScript is called:
> >
> > > function fOnSuccess(e) {
> > > var response = e.responseText.evalJSON();
> > > // TODO : Tester response.status
> > > var dt = new google.visualization.DataTable(response.table,
> > > response.version);
> > > var chart = new google.visualization.PieChart(document.getElementById
> > > ('chart_div'));
> > > chart.draw(dt, {width: 400, height: 240, is3D: true});
> > > }
> >
> > > I'm very happy to see how Google visualization can be mixed with
> > > Grails!
> >
> > > I will certainly post a new article on this suject on my web site
> > >http://www.odelia-technologies.com.
> >
> > > Cheers,
> >
> > > Bertrand.
> >
> > > On 18 nov, 10:12, bgoetzmann <[EMAIL PROTECTED]> wrote:
> > > > I do a mistake in my last post! The server part send the string:
> >
> > > > myHandler({"version":"0.5","reqId":"1","status":"ok","table":{"cols":
> > > > [... )
> >
> > > > And when, in the client part (JavaScript in the Interner browse)
> calls
> > > > my initialize function with the following code:
> >
> > > > var query = new google.visualization.Query('http://localhost:8080/
> > > > grailsbox/visualization/data?responseHandler=myHandler');
> > > > query.send(null);
> >
> > > > my myHandler JavaScript function is well called and the graph is well
> > > > displayed on the page!
> >
> > > > To repeat the problem I got:
> >
> > > > But I remark that a JavaScript error is generated after 30 seconds. I
> > > > understood that it's because I
> > > > use null in the query.send: the API tries to call an handler.
> > > > If I use an handler: query.send(myHandler1); with myHandler1 defined
> > > > like this
> >
> > > > function myHandler1(response) {
> > > > if (response.isError()) {
> > > > alert('Error in query: ' + response.getMessage() + ' ' +
> > > > response.getDetailedMessage());
> > > > return;
> > > > }
> >
> > > > }
> >
> > > > I see an error message telling "Request timed out".
> >
> > > > What I missed? The documentation seems to say to use the Query's get
> > > > method, but it is not defined.
> >
> > > > Thank you for any help!
> >
> > > > Cheers,
> >
> > > > Bertrandhttp://www.odelia-technologies.com/
> >
> > > > On 17 nov, 18:21, bgoetzmann <[EMAIL PROTECTED]> wrote:
> >
> > > > > Hello,
> >
> > > > > I've implemented a custom data source using the powerful Grails
> > > > > framework; here how I use this source in the HTML page:
> >
> > > > > ...
> > > > > google.setOnLoadCallback(initialize);
> > > > > function initialize() {
> > > > > var query = new google.visualization.Query('
> http://localhost:8080/
> > > > > grailsbox/visualization/data?responseHandler=myHandler');
> > > > > query.send(null);}
> >
> > > > > function myHandler(response) {
> > > > > // Tester response.status
> > > > > var dt = new google.visualization.DataTable(response.table,
> > > > > response.version);
> > > > > var chart = new google.visualization.PieChart
> > > > > (document.getElementById('chart_div'));
> > > > > chart.draw(dt, {width: 400, height: 240, is3D: true});}
> >
> > > > > ...
> >
> > > > > The URL is used to fetch JSON data (using a Grails controller
> action):
> >
> > > > > {"version":"0.5","reqId":"1","status":"ok","table":{"cols":[...
> >
> > > > > All is OK: the graph is displayed! But I remark that a JavaScript
> > > > > error is generated after 30 seconds. I understood that it's because
> I
> > > > > use null in the query.send: the API tries to call an handler.
> > > > > If I use an handler: query.send(myHandler1); with myHandler1
> defined
> > > > > like this
> >
> > > > > function myHandler1(response) {
> > > > > if (response.isError()) {
> > > > > alert('Error in query: ' + response.getMessage() + ' ' +
> > > > > response.getDetailedMessage());
> > > > > return;
> > > > > }
> >
> > > > > }
> >
> > > > > I see an error message telling "Request timed out".
> >
> > > > > What I missed? The documentation seems to say to use the Query's
> get
> > > > > method, but it is not defined.
> >
> > > > > Thank you for any help!
> >
> > > > > Cheers,
> >
> > > > > Bertrandhttp://www.odelia-technologies.com/-Masquer le texte des
> > > messages précédents -
> >
> > > > - Afficher le texte des messages précédents -- Masquer le texte des
> messages précédents -
> >
> > - Afficher le texte des messages précédents -
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---