View Full Version : problems with loading data from file json

30 May 2011, 7:53 AM
I'm trying to play the published Sencha Touch example named "o'really" (http://dev.sencha.com/deploy/touch/examples/oreilly/).

The js source code in object is the follow (file sessionList.js in the example):

this.list = new Ext.List({
grouped: true,
itemTpl: '<span class="name">{title}</span> <span class="secondary">{room}</span>',
loadingText: false,
store: new Ext.data.Store({
model: 'Proposal',
sorters: 'time',
getGroupString: function(r){
return r.get('pretty_time');
proxy: {
//url : 'https://en.oreilly.com/' + this.shortUrl + '/public/mobile_app/all', <-- example URL
url : 'http://myserver:myport/myservice/all', //<-- my URL
type: 'scripttag',
reader: {
type: 'json',
root: 'proposals'
listeners: {
load: { fn: this.initializeData, scope: this }

This js is served by a simple java servlet like this:

public void service (HttpServletRequest arg0, HttpServletResponse response) throws ServletException, IOException {
try {
String json = "{\"proposals\":[{\"proposal_type\":\"Plenary\",\"room\"...etc...etc..."); // <-- The string is copied by original url and escaped.
response.setCharacterEncoding ("ISO-8859-1");
response.setContentType ("application/json");
response.setContentLength (json.getBytes ("UTF8").length);
Writer out;
out = response.getWriter ();
out.write (json);
out.flush ();
} catch (Exception e) {
throw new ServletException ("I don't work :(", e);

Running the example in Google Chrome the result is a warning (normal warning, IMHO) and an error.

The warning is : Resource interpreted as Script but transferred with MIME type application/json.
The error is: Uncaught SyntaxError: Unexpected token :

Nothing more than this.

Is there someone can tell me where I did wrong?

Thank you