SyntaxError: Unexpected token '<' when using Query

870 views
Skip to first unread message

Nick Dunbar

unread,
Apr 21, 2017, 10:47:57 AM4/21/17
to Google Visualization API
Hi, 

I have started using a cloud storage system, Zoho Docs, for uploading spreadsheet data into the visualization API using the Query function. I used to do this with Google sheets but had to switch because a client had a compliance issue with Google docs. 

Unfortunately, Zoho's shared URLs don't load into Query - it throws an error "SyntaxError: Unexpected token '<'", and examination of the console shows that the URL source has <!DOCTYPE html > at the beginning which results in the error. 

Is there a way of putting an argument into Query such that it skips over HTML tags and just reads the Javascript in the Zoho file? All help with this would be much appreciated. 

Best regards, 

Nick 

Daniel LaLiberte

unread,
Apr 21, 2017, 3:28:15 PM4/21/17
to Google Visualization API
Sorry Nick, but there is no option for processing the response in other ways.  Basically, the response must either be JSON or CSV.  There is also a jsonp mechanism, but that also requires JS notation.

But you could always use another query library, such as the one that jQuery has.  There is not a way to use this with the ChartWrapper, however, if that is what you are thinking of, unless you maybe override the google.visualization.Query function with your own.  That sounds like a lot of work, if it will work at all.


--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/ce935b7e-9aed-445a-bb0a-dc3319bc7b83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Nick Dunbar

unread,
Apr 22, 2017, 5:02:58 AM4/22/17
to Google Visualization API
Hi Dan, 

Thanks for getting back to me. 

Just so I understand, what response does Google sheets provide - JSON or CSV? I have gotten so used to the seamless way that Google sheets works with the Query function that doing something outside the framework looks like a lot of work. 

However, people tell me I should not bother with another 3rd party cloud document storage system but instead bite the bullet and set up my own MySQL data hosting in a way that works with Query function and my library of existing Google chart scripts. From looking at this forum, it appears quite a few users have done something like that. 

Do you know of any documentation or cheat sheet that makes it straightforward to do this? Any suggestions or advice would be welcome. 

Best regards, 
NIck 



On Friday, April 21, 2017 at 8:28:15 PM UTC+1, Daniel LaLiberte wrote:
Sorry Nick, but there is no option for processing the response in other ways.  Basically, the response must either be JSON or CSV.  There is also a jsonp mechanism, but that also requires JS notation.

But you could always use another query library, such as the one that jQuery has.  There is not a way to use this with the ChartWrapper, however, if that is what you are thinking of, unless you maybe override the google.visualization.Query function with your own.  That sounds like a lot of work, if it will work at all.

On Fri, Apr 21, 2017 at 10:47 AM, Nick Dunbar <dunba...@gmail.com> wrote:
Hi, 

I have started using a cloud storage system, Zoho Docs, for uploading spreadsheet data into the visualization API using the Query function. I used to do this with Google sheets but had to switch because a client had a compliance issue with Google docs. 

Unfortunately, Zoho's shared URLs don't load into Query - it throws an error "SyntaxError: Unexpected token '<'", and examination of the console shows that the URL source has <!DOCTYPE html > at the beginning which results in the error. 

Is there a way of putting an argument into Query such that it skips over HTML tags and just reads the Javascript in the Zoho file? All help with this would be much appreciated. 

Best regards, 

Nick 

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.



--

Daniel LaLiberte

unread,
Apr 22, 2017, 10:39:37 AM4/22/17
to Google Visualization API
Whether you get JSON or CSV depends on the request you make.  I don't see documentation about an option in the Query class, but the URL makes a difference.  See: 


I see also that there is a way of requesting an HTML table.  Not sure that still works, and you don't get a DataTable that you can use with other charts.  I know the TSV method is now broken.

Also see other pages for some possibly useful hints.



On Sat, Apr 22, 2017 at 5:02 AM, Nick Dunbar <dunba...@gmail.com> wrote:
Hi Dan, 

Thanks for getting back to me. 

Just so I understand, what response does Google sheets provide - JSON or CSV? I have gotten so used to the seamless way that Google sheets works with the Query function that doing something outside the framework looks like a lot of work. 

However, people tell me I should not bother with another 3rd party cloud document storage system but instead bite the bullet and set up my own MySQL data hosting in a way that works with Query function and my library of existing Google chart scripts. From looking at this forum, it appears quite a few users have done something like that. 

Do you know of any documentation or cheat sheet that makes it straightforward to do this? Any suggestions or advice would be welcome. 

Best regards, 
NIck 



On Friday, April 21, 2017 at 8:28:15 PM UTC+1, Daniel LaLiberte wrote:
Sorry Nick, but there is no option for processing the response in other ways.  Basically, the response must either be JSON or CSV.  There is also a jsonp mechanism, but that also requires JS notation.

But you could always use another query library, such as the one that jQuery has.  There is not a way to use this with the ChartWrapper, however, if that is what you are thinking of, unless you maybe override the google.visualization.Query function with your own.  That sounds like a lot of work, if it will work at all.

On Fri, Apr 21, 2017 at 10:47 AM, Nick Dunbar <dunba...@gmail.com> wrote:
Hi, 

I have started using a cloud storage system, Zoho Docs, for uploading spreadsheet data into the visualization API using the Query function. I used to do this with Google sheets but had to switch because a client had a compliance issue with Google docs. 

Unfortunately, Zoho's shared URLs don't load into Query - it throws an error "SyntaxError: Unexpected token '<'", and examination of the console shows that the URL source has <!DOCTYPE html > at the beginning which results in the error. 

Is there a way of putting an argument into Query such that it skips over HTML tags and just reads the Javascript in the Zoho file? All help with this would be much appreciated. 

Best regards, 

Nick 

--
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 google-visualization-api+unsubscr...@googlegroups.com.



--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages