Reputation: 3978
I'm querying a google fusion table via jquery ajax:
var queryUrlStart = 'http://www.google.com/fusiontables/api/query?sql=';
var queryUrlEnd = '&jsonCallback=?'; // ? could be a function name
var sql = "SELECT * FROM " + this.tableId;
if (where !== undefined) {
sql += " WHERE " + where;
}
sql += " ORDER BY '" + _scaleRow.name + "' DESC";
var queryUrl = encodeURI(queryUrlStart + sql + queryUrlEnd);
$.ajax({
type: 'POST',
context: this,
url: queryUrl,
dataType: 'json',
success: this.handleData
});
I'd like to be able to know which table is being queried so I'd like to add an extra parameter to identify it. I tried:
$.ajax({
type: 'POST',
context: this,
data: {'table' : this.tableId}
url: queryUrl,
dataType: 'json',
success: this.handleData
});
But I don't see it anywhere where I can retrieve table
Upvotes: 3
Views: 500
Reputation: 117334
There may be different ways, e.g. the following:
$.ajax({
context: this,
url: queryUrl,
dataType: 'json',
beforeSend:(function(data){return function(jqXhr){jqXhr.data=data}})
({'table' : this.tableId}),
success: this.handleData
});
It uses the beforeSend-method to add a new property to the jqXhr-object. The jqXhr-object may be accessed in the success-callback(it's the 3rd argument), so this would be an example for your success-callback:
handleData=function(data,status,jqXhr){
alert('results for table:'+jqXhr.data.table);
};
Upvotes: 1