$.get

Showing 1-20 of 20 messages
$.get Dan 12/19/10 9:39 AM
I am trying to retrieve single values from a fusion table using the
API. I have formatted a get request:

http://www.google.com/fusiontables/api/query?hdrs=false&sql=SELECT%20G%20FROM%20358855%20WHERE%20name%20%3D%20'Barking%20and%20Dagenham%20001A'

which works perfectly in a browser and returns the correct value.

When I try the same thing in jQuery I get a response of 'undefined'

function gogetit(){
var content;
$.get("http://www.google.com/fusiontables/api/query?hdrs%3Dfalse%26sql
%3DSELECT%2520G%2520FROM%2520358855%2520WHERE%2520name%2520%253D

%2520%27Barking%2520and%2520Dagenham%2520001A%27", function(data){
    content= data;
});
alert(content);}

I am sure there is a simple explanation but I have tried it in so many
different ways that I ahve run out of ideas. Any suggestions much
appreciated!
Re: $.get Fusion Tables Team 12/20/10 6:50 PM
Hi Dan,

Since the domain of the URL in your GET request is different than the calling domain, the GET request will not work. We're working on a good solution for developers.

Cheers,
Kathryn


--
You received this message because you are subscribed to the Google Groups "Fusion Tables Users Group" group.
To post to this group, send email to fusion-table...@googlegroups.com.
To unsubscribe from this group, send email to fusion-tables-users-group+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fusion-tables-users-group?hl=en.


Re: $.get boris.lo...@gmail.com 5/30/11 3:51 PM
Hello,

I was wondering if there have been any updates to this question. If not, if I'm implementing my project in Javascript, what's the best way to query the Fusion tables for data if I'd like to use it in the application and not add to a layer? 

Thanks!
Re: $.get Robin Kraft 5/31/11 7:02 PM
Hi Boris,

I was having the same problem a few weeks ago! Turns out that you just
need to specify that you're retrieving a jsonp object when you use
$.get(). It's not so bad, but it isn't obvious if you're new to this,
like I am.

tableid = 274408;

query = 'SELECT customer FROM ' + tableid; // easier to write pure
queries

head = 'http://www.google.com/fusiontables/api/query?sql=';
tail = '&jsonCallback=?'; // tell fusion tables you want a json object

queryurl = encodeURI(head + query + tail); // encodeURI takes care of
any weird characters or punctuation

$.get(queryurl, handler, "jsonp");

function handler(data) {
    // do stuff with the data here, dispatch it to other functions,
etc.

    alert(data.table.cols);  // cols is an array of column names
    alert(data.table.rows); // rows is array of rows
}


Good luck!

-Robin
Re: $.get Kathryn from Fusion Tables Team 6/1/11 9:09 AM
Hi all,

I need to do my due diligence here and let you know that jsonp does work; however, it is undocumented and subject to change.

Please let me know if you have any questions.

Kathryn


--
You received this message because you are subscribed to the Google Groups "Fusion Tables Users Group" group.
To post to this group, send email to fusion-table...@googlegroups.com.
To unsubscribe from this group, send email to fusion-tables-users-group+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fusion-tables-users-group?hl=en.


Re: $.get Robin Kraft 6/1/11 10:30 AM
Hi Kathryn,

Thanks for the heads up! I hope your team will keep jsonp around for a
while, and give fair warning if it's going to be removed. It's nice
and simple, and just works. I strongly recommend documenting it!

For the app I'm building I could simply pre-cache query results, but
that kind of defeats the purpose of using Fusion Tables.

So, is there any alternative method for interacting with Fusion Tables
using Javascript? I really want to avoid using a server intermediary!
It just makes life more complicated without any real benefit - in my
case at least.

Best,
Robin
Re: $.get Kathryn from Fusion Tables Team 6/2/11 10:19 AM
Hi Robin,


Thanks for the heads up! I hope your team will keep jsonp around for a
while, and give fair warning if it's going to be removed. It's nice
and simple, and just works. I strongly recommend documenting it!

There are no plans for removal, but changes to the interface / syntax might occur sometime down the road. We know a lot of people are using it, so we will send out a notification on the forum before any changes are made.


For the app I'm building I could simply pre-cache query results, but
that kind of defeats the purpose of using Fusion Tables.

So, is there any alternative method for interacting with Fusion Tables
using Javascript? I really want to avoid using a server intermediary!
It just makes life more complicated without any real benefit - in my
case at least.

An alternative is the Google Chart API, but it has it's limitations (you can only request up to 500 rows of data). If you're interested, sample code can be found here:


Cheers,
Kathryn

Re: $.get Daniel Lathrop 6/2/11 6:08 PM
I think the JSONP functionality is one of the best and most valuable
features of Fusion Tables.

Just going to put another plug in for addressing the header issue on
it that exists for IE9. IE9 doesn't like JSONP using the combination
of a "nosniff" header and an application/json mime type.

http://blogs.msdn.com/b/ie/archive/2010/10/26/mime-handling-changes-in-internet-explorer.aspx

Right now the jQuery plug-in I'm working on and planning to release
ASAP for displaying searchable data widgets depends on the JSONP
functionality. Also, if this is definitely not going to be "fixed" I
need to figure out s new IE9 strategy for my code.

Thanks,
Daniel Lathrop
The Dallas Morning News


On Jun 2, 12:19 pm, Kathryn from Fusion Tables Team <googletables-
Re: $.get Robin Kraft 6/3/11 10:47 AM
Daniel,

Do you have an idea for a workaround? I never use IE (and don't know
anyone who does) so it didn't even occur to me that this might be an
issue, but I suppose I can't count on that ...

Best,
Robin


On Jun 2, 9:08 pm, Daniel Lathrop <daniel.lath...@gmail.com> wrote:
> I think the JSONP functionality is one of the best and most valuable
> features of Fusion Tables.
>
> Just going to put another plug in for addressing the header issue on
> it that exists for IE9. IE9 doesn't like JSONP using the combination
> of a "nosniff" header and an application/json mime type.
>
> http://blogs.msdn.com/b/ie/archive/2010/10/26/mime-handling-changes-i...
Re: $.get Robin Kraft 6/3/11 10:51 AM
Kathryn,

The charts API might work in a pinch, but I'm typically requesting
500-1000 rows. I'm happy to hear that the JSONP should stick around.
As long as some JSONP interface exists I don't mind so much if the
syntax changes - that's an easy fix. I just don't want to have to
totally revamp my data handling functions!

Best,
Robin
Re: $.get Daniel Lathrop 6/3/11 12:34 PM
OK... After more playing it looks like another workaround for IE9
could be to use the regular CSV resultset, but that would require
proper CORS headers i.e.

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: <allowed methods>

And those aren't there right now either, at least my browser isn't
seeing them.

For more see: http://en.wikipedia.org/wiki/List_of_Web_services_allowing_access_from_any_origin

So... Help! I want to do client-side Fusion Tables but it won't work
either way in IE9. Something in the response headers needs to be
tweaked.

-Daniel
Re: $.get Daniel Lathrop 6/3/11 11:58 AM
Possibly something involving IFrames. Since I'm using jQuery I may be
able to futz with the mime-type by virtue the JQXHR function. Will let
the group know. Of course my main hope is that Kathryn gets the team
to fix it for us.

=)
Re: $.get Daniel Lathrop 6/3/11 11:46 AM
I'm thinking about something involving hidden IFrames. And, FWIW, only
IE9 has the problem. It works just fine on IE7 and IE8 (haven't tested
on IE6 but don't know why it wouldn't). Ohhhh Microsoft.

-Daniel

On Jun 3, 12:47 pm, Robin Kraft <robinkr...@gmail.com> wrote:
Re: $.get Kathryn from Fusion Tables Team 6/3/11 5:04 PM
Hi Daniel,

OK... After more playing it looks like another workaround for IE9
could be to use the regular CSV resultset, but that would require
proper CORS headers i.e.

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: <allowed methods>

Please feel free to open a feature request for this:


Sincerely,
Kathryn
Re: $.get JasonCOL 6/22/11 1:04 PM
I've had issues using the chart api query function (I assume we are
referring to google.visualization.Query) in IE9. Again, it has to do
with the headers...A fix on the Google end (for both the visualization
query headers and the JSONP headers) would be appreciated.

Jason
Re: $.get Kathryn from Fusion Tables Team 6/23/11 4:37 PM
Hi Jason,

The JSONP headers have been fixed. Are you still having the same issue with IE9? Does your data have any special characters?

Thanks,
Kathryn


--
You received this message because you are subscribed to the Google Groups "Fusion Tables Users Group" group.
To post to this group, send email to fusion-table...@googlegroups.com.
To unsubscribe from this group, send email to fusion-tables-users-group+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fusion-tables-users-group?hl=en.


Re: $.get JasonCOL 7/10/11 7:41 PM
Sorry Kathryn, I hadn't seen your response to this before now.  Yes,
visualization api's 'query' function still does not work in IE9 for
us. I believe it is the header issue. I am going to test the JSONP
route though because I would prefer to use Fusion Table API functions
for Fusion Tables data rather than a separate api (ie the GViz Query
API).

Thanks for all of your help.
Jason
Re: $.get Kathryn from Fusion Tables Team 7/11/11 1:15 PM
FYI - We have fixed the headers in the Google Chart Tools API response.

Kathryn

Jason

--
You received this message because you are subscribed to the Google Groups "Fusion Tables Users Group" group.
To post to this group, send email to fusion-table...@googlegroups.com.
To unsubscribe from this group, send email to fusion-tables-users-group+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fusion-tables-users-group?hl=en.


Re: $.get Robin Kraft 8/10/11 2:02 PM
For future readers of this thread on $.get and JSONP, I just wrote a
blogpost describing how to use $.get to query a table and add markers
to a map.

http://www.reddmetrics.com/2011/08/10/fusion-tables-javascript-query-maps.html

Hope this helps someone!

-Robin
Re: $.get Bob Torzynski 8/11/11 11:47 AM
Thank you, Robin! I know it will help me :)

On Aug 10, 5:02 pm, Robin Kraft <robinkr...@gmail.com> wrote:
> For future readers of this thread on $.get and JSONP, I just wrote a
> blogpost describing how to use $.get to query a table and add markers
> to a map.
>
> http://www.reddmetrics.com/2011/08/10/fusion-tables-javascript-query-...