# Yahoo! UI Library

### AutoComplete Widget 2.5.0

Yahoo! UI Library > autocomplete > YAHOO.widget.DS_XHR

Show Private Show Protected

## Class YAHOO.widget.DS_XHR - extends YAHOO.widget.DataSource

Implementation of YAHOO.widget.DataSource using XML HTTP requests that return query results.

### Constructor

YAHOO.widget.DS_XHR `( sScriptURI , aSchema , oConfigs )`

Parameters:
  `sScriptURI <String>` Absolute or relative URI to script that returns query results as JSON, XML, or delimited flat-file data.
  `aSchema <String[]>` Data schema definition of results.
  `oConfigs <Object>` (optional) Object literal of config params.

### Properties

#### _oConn `- private Object`

XHR connection object.

#### connMgr `- Object`

Alias to YUI Connection Manager, to allow implementers to customize the utility.
Default Value: YAHOO.util.Connect

#### connTimeout `- Number`

Number of milliseconds the XHR connection will wait for a server response. A a value of zero indicates the XHR connection will wait forever. Any value greater than zero will use the Connection utility's Auto-Abort feature.
Default Value: 0

#### ERROR_DATAXHR `- static final String`

Error message for XHR failure.

#### responseStripAfter `- String`

String after which to strip results. If the results from the XHR are sent back as HTML, the gzip HTML comment appears at the end of the data and should be ignored.
Default Value: "\n<!-"

#### responseType `- String`

XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML and YAHOO.widget.DS_XHR.TYPE_FLAT.
Default Value: YAHOO.widget.DS_XHR.TYPE_JSON

#### scriptQueryAppend `- String`

String of key/value pairs to append to requests made to scriptURI. Define this string when you want to send additional query parameters to your script. When defined, queries will be sent to <scriptURI>?<scriptQueryParam>=userinput&<scriptQueryAppend>
Default Value: ""

#### scriptQueryParam `- String`

Query string parameter name sent to scriptURI. For instance, queries will be sent to <scriptURI>?<scriptQueryParam>=userinput
Default Value: "query"

#### scriptURI `- String`

Absolute or relative URI to script that returns query results. For instance, queries will be sent to <scriptURI>?<scriptQueryParam>=userinput

#### TYPE_FLAT `- static final Number`

Flat-file data type.

#### TYPE_JSON `- static final Number`

JSON data type.

#### TYPE_XML `- static final Number`

XML data type.

#### Properties inherited from YAHOO.widget.DataSource:

`_aCache, _sName, maxCacheEntries, queryMatchCase, queryMatchContains, queryMatchSubset`

### Methods

#### doQuery

`void doQuery ( oCallbackFn , sQuery , oParent )`
Queries the live data source defined by scriptURI for results. Results are passed back to a callback function.

Parameters:
  `oCallbackFn <HTMLFunction>` Callback function defined by oParent object to which to return results.
  `sQuery <String>` Query string.
  `oParent <Object>` The object instance that has requested data.

Returns: `void`

#### parseResponse

`void parseResponse ( sQuery , oResponse , oParent )`
Parses raw response data into an array of result objects. The result data key is always stashed in the [0] element of each result object.

Parameters:
  `sQuery <String>` Query string.
  `oResponse <Object>` The raw response data to parse.
  `oParent <Object>` The object instance that has requested data.

Returns: `void`

#### Methods inherited from YAHOO.widget.DataSource:

`_addCacheElem, _doQueryCache, _init, doQuery, flushCache, getResults, toString`

#### Events inherited from YAHOO.widget.DataSource:

`cacheFlushEvent, cacheQueryEvent, dataErrorEvent, getCachedResultsEvent getResultsEvent queryEvent`

Copyright © 2007 Yahoo! Inc. All rights reserved.