There are a handful of problems with this script. First, you should have your sparqlQueryJson function defined in scope for both queries, not just query1. Second, the query is never called for query2, which is the primary reason it doesn't work. Third, AJAX is - by definition - asynchronous. You cannot call the sparqlQueryJson function and then use its return value right away, as it may not have returned yet. You should only use the return value inside the callback from the AJAX. Here's an example fiddle that should address these points: http://jsfiddle.net/asgallant/Wd8A5/2/
I made another small change as well: to ensure that the Visualization API is loaded before the user tries to draw anything, I set up the event handler for your submit button in a callback from the google loader. On Saturday, March 29, 2014 7:02:05 AM UTC-4, Mariona gasull soler wrote: > > I have been stuck on this problem and I know its something small but > cannot get it working. > > I have two queries and I want the user to have an option of what query > they want to display and what type of graph. I can get one working but not > at the same time. I always get one says no data and the other displays and > vice a versa. > > Maybe a another set of eyes will help? > > This is a jsfiddle of my code > > http://jsfiddle.net/degzs/Wd8A5/ > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/d/optout.
