View Full Version : Grid not populated via json request using ScriptTagProxy

28 Mar 2011, 3:39 AM
I'm trying to use ScriptTagProxy to load a grid with data received from a Tornado web server. My original server is Django based. My code works if I request the json data from the originating Django server but it fails as soon as I switch to using cross domain scripting. Firebug shows the json response arrives from Tornado but the grid isn't populated.

My javascript:

RoomListPanel = Ext.extend(Ext.grid.GridPanel, {

initComponent: function() {

this.createRoomButton = new Ext.Button({
text: 'Create Room',
id: 'create-room-button',
listeners: {
click: function() {
alert('Creating room');

this.joinRoomButton = new Ext.Button({
text: 'Join Room',
id: 'join-room-button',
listeners: {
click: function() {
alert('Joining room');

Ext.apply(this, {
tbar: [

store: new Ext.data.JsonStore({
// store configs
autoLoad: true,
proxy: new Ext.data.ScriptTagProxy({
url: 'http://localhost:8888/'
//~ url: ''

// reader configs
root: 'rooms',
fields: ['name', 'title', 'public', 'owner']


RoomListPanel.superclass.initComponent.call(this, arguments);

colModel: new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
columns: [
{header: 'Name', dataIndex: 'name'},
{header: 'Title', dataIndex: 'title'},
{header: 'Public', dataIndex: 'public'},
{header: 'Owner', dataIndex: 'owner'},

// register xtype to allow for lazy initialization
Ext.reg('roomlistpanel', RoomListPanel);

var chatPanel = new RoomListPanel({
title: 'Chat Rooms',
width: 600,
height: 300,
renderTo: document.body

And my Tornado code is:

import tornado.ioloop
import tornado.web
import tornado

class MainHandler(tornado.web.RequestHandler):
def get(self):
data = {
"response": True,
"rooms": [{
'name': 'support',
'title': 'Support Room',
'public': True,
'owner': 'Mike',
resp = tornado.escape.json_encode(data)
print('Returning list of rooms')

application = tornado.web.Application([
(r"/", MainHandler),

if __name__ == "__main__":

Any suggestions appreciated. Thanks

28 Mar 2011, 4:55 AM
Oops forgot to FULLY read the docs:

The content passed back from a server resource requested by a ScriptTagProxy must be executable JavaScript source code because it is used as the source inside a <script> tag.