Hi Everyone,
I am having trouble running a code that uses JSON to build a YUI DataTable. I’m using YUI 2.8.2.1 and running an Apache 2.2 server in Windows XP.
I hardcoded the DataSource as a JSON string that looks like the following:
{"data":[{"id":"1","lastname":"Moore","firstname":"Demi"},{"id":"2","lastname":"Potter","firstname":"Harry"}]}
The code for the page follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User List No Server</title>
<!-- YAHOO Global Object source file -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.2r1/build/yahoo/yahoo-min.js"></script>
<!-- Event source file -->
<script src="http://yui.yahooapis.com/2.8.2r1/build/event/event-min.js" ></script>
<!-- include style -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.2r1/build/tabview/assets/skins/sam/tabview.css">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.2r1/build/datatable/assets/skins/sam/datatable.css">
<style type="text/css">
/*Nothing*/
</style>
<!-- javascript -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.2r1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.2r1/build/element/element-beta-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.2r1/build/connection/connection-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.2r1/build/datasource/datasource-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.2r1/build/datatable/datatable-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.2r1/build/json/json-min.js"></script>
</head>
<body class="yui-skin-sam">
<h3>User List</h3>
<div id="container"></div>
<script type="text/javascript">
YAHOO.example.Data = {"data":[{"id":"1","lastname":"Moore","firstname":"Demi"},{"id":"2","lastname":"Potter","firstname":"Harry"}]};
YAHOO.util.Event.addListener(window, "load", function(){
YAHOO.example.Basic = function(){
var columnDesc = [
{key:"id", sortable:true, resizeable:true},
{key:"lastname", sortable:true, resizeable:true},
{key:"firstname", sortable:true, resizeable:true}
];
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.data);
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSource.responseSchema = {
resourceList: "data",
fields: ["id", "lastname", "firstname"]
};
var myDataTable = new YAHOO.widget.DataTable("container", columnDesc, myDataSource);
}();
});
</script>
</body>
</html>
The error that I get is "Invalid callback for subscriber to ‘end’ at line 11 character 4854.
Any help is appreciated. Thank you in advance.
Regards,
Rubiks