Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
73 Cards in this Set
- Front
- Back
define XHR
|
Refers to XMLHttpRequest, a method implemented by standards compliant browsers to receive asynchronous requests in JavaScript
|
|
define AJAX
|
Asynchronous JavaScript and XML
|
|
where did AJAX get its origins?
|
As part of Outlook Web Access, Microsoft released an ActiveX control in 1998. It wasn't made popular until Google used it in 2005
|
|
Describe difference between AJAX implementations in IE 6 and 7
|
IE 7 uses a wrapper that is compliant with the XHR standard, instead of IE 6's active X call.
|
|
(true or false) jQuery uses the new IE 7 wrapper for XHR
|
As of 1.4, this is false; jQuery feels that the wrapper in IE 7 is buggy, so it goes straight to the source
|
|
Define the XHR method: abort() method
|
cancels currently executing request
|
|
Define the XHR method: getAllResponseHeaders()
|
returns string containing the names and values of all response headers
|
|
Define the XHR method: getResponseHeader(name)
|
returns value of one header
|
|
Define the XHR method: open(method,url,async,user,pass)
|
Sets the HTTP request method (GET or POST) and URL to be requested. Other parms are optional
|
|
What is the purpose of async in this method: open(method,url,async)
|
async is true by default, is false, the request is much like normal HTTP (synchronous, not loaded in background)
|
|
Define the XHR method: send(content)
|
initiates XHR request with 'content' as the body of the request
|
|
Define the XHR method: setRequestHeader(key, value)
|
sets a request header used in the XHR request
|
|
Define the XHR property: onreadystatechange
|
The event handler invoked when the request is returned or fails.
|
|
Define the XHR property: readyState
|
Integer representing current state:
0 - UNSENT 1 - OPENED 2 - HEADERS_RECEIVED 3 - LOADING 4 - DONE |
|
Define the XHR property: responseText
|
body content returned in the response
|
|
Define the XHR property: responseXML
|
if the body was XML content, this is the DOM structure for that content
|
|
Define the XHR property: status
|
HTTP response code from the server: 200/success; 400/not found
|
|
Define the XHR property: statusText
|
description of the HTTP response code
|
|
when using ajax queries, what do status codes 200-299 represent?
|
success (these are actually the HTTP request codes)
|
|
when using ajax queries, what do status codes of 300 or above represent?
|
failures (these are actually the HTTP request codes)
|
|
explain the purpose of the $(...).load() method
|
sends an XHR request via get or post, depending on the arguments passed, loads the results into each element of the wrapped set
|
|
explain the params argument in $(...).load(url, params, callback) and its effect on the request type
|
an optional string, array, or object
if omitted, GET method is used as a string, it is a query string and GET is used as an array, each element is an object formatted: {name: "name", value: "the val} and POST is called as an object, POST is called |
|
explain the callback argument in $(...).load(url, params, callback)
|
optional
It receives two arguments: response text (i.e. 'success'), and the XHR instance invoked once for each element in the wrapped set with 'this' equal to DOM element being iterated |
|
explain how to force $('...').load() method to use the GET method when passing arguments
|
place the arguments into the URL parameter using encodeURIComponent() or $.param()
|
|
explain how to filter the results of $('...).load() so that only div elements are inserted into the wrapped set
|
put a space and a selector onto the url, for example:
$('...').load("/xhr.php div"); |
|
what method can be used to prepare form data for use as an argument to jQuery XHR methods?
|
$(...).serialize()
Any form elements in the wrapped set are used. If forms exist in the wrapped set, all their elements are used. |
|
explain the purpose of $(...).serializeArray()
|
returns form elements as array of {name: ..., value: ...} objects suitable for use with jQuery XHR methods
|
|
what jQuery utility method executes a GET request?
|
$.get(...)
|
|
what are the valid data types for parms in:
$.get(url, parms, callback, type) |
query string, array of name/value objects, or JS object
|
|
explain the callback parm in:
$.get(url, parms, callback, type) |
method called when $.get() returns
|
|
explain possible values of the dataType property passed to the $.ajax() utility method
Hint: It is the same as the type argument in $.get(url, parms, callback, type) |
xml, html, json, jsonp, script, text
|
|
When setting properties for $.ajax() method, explain the dataType of 'xml'
|
returns XML DOM object parsed from the returned text body
|
|
When setting properties for $.ajax() method, explain the dataType of 'jsonp'
|
similar to json, except remote scripting is allowed
|
|
What happens to <script> tags when setting the dataType for jQuery's $.ajax() method to 'html'?
|
they are evaluated when inserted into the DOM
|
|
what method returns AJAX call in JSON format?
|
$.getJSON(url, parameters, callback)
returned JSON object is passed to callback |
|
what type of HTTP request does $.getJSON() utilize?
|
GET request
|
|
what is the purpose of callback in $.getJSON(url, parms, callback)
|
receives the JSON object returned
|
|
what jQuery utility creates an HTTP request with type POST?
|
$.post()
|
|
what jQuery utility method provides advanced control over execution of XHR requests?
|
$.ajax(options)
|
|
explain the $.ajax() option: type
|
the HTTP request type (GET or POST)
defaults to GET |
|
explain the $.ajax() option: data
|
a query string, JS object, or array of name/value objects
Passed in the url for GET requests, as part of body for POST requests. |
|
explain the $.ajax() option: dataType
|
Defines the format of the returned data. If omitted, jQuery will guess based on returned content
One of xml, html, json, jsonp, script, or text |
|
when using $.ajax(), the property dataType can be set to 'script' - what does this do?
|
executes the returned value as JS statements, then passes it to the callback (if any)
|
|
explain the $.ajax() option: cache
|
if false, ensures response is not cached by the browser
|
|
in what cases does the $.ajax() cache option default to true?
|
All cases except when dataType is set to jsonp or script
|
|
explain the $.ajax() option: context
|
overrides 'this', setting the context for all callback invocations
|
|
explain the $.ajax() option: timeout
|
milliseconds until timeout, if expired, request is aborted and error callback is invoked (if defined)
|
|
explain the $.ajax() option: global
|
if false, disables triggering of jQuery global ajax events, defaults to true (enabled)
|
|
explain the $.ajax() option: contentType
|
content type specified in HTTP request, defaults to application/x-www-form-urlencoded (default for form submissions)
|
|
explain the $.ajax() option: success
|
a function invoked if request succeeds
first parm is request body, second is the text 'success', third is XHR instance |
|
explain the $.ajax() option: error
|
a function invoked if request fails
first parm is request body, second is the text 'error|timeout|notmodified|parseerror', third is XHR instance |
|
explain the $.ajax() option: complete
|
called after error or success callbacks (if they are defined), receives XHR instance and status string
|
|
explain the $.ajax() option: beforeSend
|
called before initiating request, receives XHR instance as param
returning false from this callback cancels the request |
|
explain the $.ajax() option: async
|
defaults to true, if set to false, synchronous request is sent (blocks browser activity just like a page load)
|
|
explain the $.ajax() option: processData
|
if false, data passed is not processed into a url-encoded format
|
|
explain the $.ajax() option: dataFilter
|
callback function called to filter result data, passed the raw result data and dataType value, must return the "sanitized" data
|
|
explain the $.ajax() option: ifModified
|
if true, request succeeds only if response content has not changed since last request, according to the Last-Modified header, defaults to false
|
|
explain the $.ajax() option: jsonp
|
overrides the default jsonp callback parameter
|
|
explain the $.ajax() option: scriptCharset
|
the character set used for script and jsonp requests when remote and local have diff charsets
|
|
explain the $.ajax() option: xhr
|
a callback used to provide custom implementation of the XHR method
|
|
explain the $.ajax() option: traditional
|
if true, traditional parameter stylization is used (see $.param())
|
|
how can one set a default list of ajax options instead of passing them each time to $.ajax()?
|
$.ajaxSetup(options)
|
|
(true or false) defaults set with $.ajaxSetup() also affect the $(...).load() method
|
false, additionally, overriding the type option has no effect on $.get() and $.post() util methods (they igonore it)
|
|
What method is used to establish global listeners for Ajax requests?
|
$.bind(), just like any other listeners in jQuery
|
|
What are the Ajax related events that can be monitored?
|
ajaxStart, ajaxSend, ajaxSuccess, ajaxError, ajaxStop, and ajaxComplete
|
|
What arguments are given to the listeners for ajaxStart events?
|
none
|
|
What arguments are given to the listeners for beforeSend events?
|
the XHR instance
|
|
What happens if the listener for beforeSend returns false?
|
the XHR is canceled
|
|
What arguments are given to the listeners for ajaxSend events?
|
jQuery.Event, XHR instance, and options passed to $.ajax()
|
|
What arguments are given to the listeners for ajaxSuccess events?
|
jQuery.Event, XHR instance, and options passed to $.ajax()
|
|
What arguments are given to the listeners for ajaxComplete events?
|
jQuery.Event, XHR instance, and options passed to $.ajax()
|
|
What ajax event is always triggered, even for synchronous events?
|
ajaxComplete
|
|
What arguments are given to the listeners for ajaxError
|
jQuery.Event, XHR instance, options passed to $.ajax(), and the error as an optional 4th parameter
|