I modified the sample to use your code (doBuffer) and it worked for me. In my test I just use the map's extent to generate the buffer. Do you see any errors in Firebug or the Chrome Developer Tools console when you run your code?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>QueryTask with query geometry from another task</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("esri.tasks.query");
dojo.require("esri.tasks.geometry");
var queryTask;
var map;
var gsvc;
function init() {
var startExtent = new esri.geometry.Extent({"xmin":-10605514,"ymin":4712767,"xmax":-10600737,"ymax":4717545,"spatialReference":{"wkid":102100}});
map = new esri.Map("mapDiv", { extent: startExtent });
//listen for when map is loaded and then add query functionality
dojo.connect(map, "onLoad", initFunctionality);
var streetMap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
map.addLayer(streetMap);
}
function initFunctionality(map) {
queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0");
//identify proxy page to use if the toJson payload to the geometry service is greater than 2000 characters.
//If this null or not available the buffer operation will not work. Otherwise it will do a http post to the proxy.
esriConfig.defaults.io.proxyUrl = "http://localhost/proxy/proxy.ashx";
esriConfig.defaults.io.alwaysUseProxy = false;
//Geometry Service Endpoint
gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
}
function doBuffer() {
var buffParams = new esri.tasks.BufferParameters();
var extent = map.extent;
buffParams.geometries = [extent];
buffParams.distances = [dojo.byId('bufferDistance').value];
buffParams.unit = esri.tasks.GeometryService.UNIT_FOOT;
buffParams.bufferSpatialReference = new esri.SpatialReference({ wkid: 3421 });
buffParams.outSpatialReference = map.spatialReference;
gsvc.buffer(buffParams);
var link1 = dojo.connect(gsvc, "onBufferComplete", function (geometries) {
var symbol1 = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
var graphic = new esri.Graphic(geometries[0], symbol1);
map.graphics.add(graphic);
query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["POP2000","HOUSEHOLDS","HSE_UNITS", "TRACT", "BLOCK"];
query.where = "";
query.geometry = graphic.geometry;
query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
queryTask.execute(query);
});
var link2 = dojo.connect(queryTask, "onComplete", function (featureSet) {
alert('Hello test');
alert(featureSet.features.length);
dojo.disconnect(link1);
dojo.disconnect(link2);
});
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
Zoom to area and click on map to select census block points within the buffered circle.<br/>
<input type='button' value='buffer' onclick='doBuffer();' />
Buffer distance (in kilometers): <input type="text" id="bufferDistance" value="1" size="5"/>
<div id="mapDiv" style="width: 500px; height:500px;"></div>
<span id="messages"></span>
</body>
</html>