ArcGIS API for JavaScript: QueryLayers/NewQueryLayers2 (MapServer)
Built using the ArcGIS API for JavaScript