YUI recommends YUI3.
YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.
This documentation is no longer maintained.
A natural fit for the JSON Utility is working with the Connection Manager. In this example, we'll request JSON data from the server using Connection Manager's asyncRequest
and parse the resulting JSON string data for processing.
Click the Get Messages button to send the request to the server.
YAHOO.lang.JSON.parse
in the success handlerPass the XHR responseText
to YAHOO.lang.JSON.parse
and capture the return value. Note that the parse method can throw a SyntaxError
exception, so be sure to wrap the call in a try/catch
block.
The parse
method returns the native JavaScript object representation of the string data returned from the asyncRequest
. In this case, the data is an array of object literals in this form:
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.