YUI3-(datasource-get, datasource-jsonschema模块实例)

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<ol id="issues"></ol>
<script src="http://yui.yahooapis.com/3.16.0/build/yui/yui-min.js"></script>
<script type="text/javascript">

YUI().use('datasource-get', 'datasource-jsonschema', 'node-base', function(Y) {

    var src = '/yuidemo/php1.php?',
        dataSource = new Y.DataSource.Get({source: src});
        //dataSource.set('scriptCallbackParam',  'callbacks');

    function displayInfo(rsp) {
        var issues = rsp.response.results,
            template = '<li><a href="#"></a>{name}</li>',
            ol = Y.one('#issues');

        Y.Array.each(issues, function(issue) {
            ol.append(Y.Lang.sub(template, issue));
        });
    }

    dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
        schema: {
            resultListLocator: 'resultData',
            resultFields: ['name']
        }
    });

    dataSource.sendRequest({
        on: {
            success: displayInfo
        }
    });

});
</script>
</body>
</html>

 

posted @ 2014-06-12 10:17  wheats  阅读(251)  评论(0编辑  收藏  举报