Hi, Roger, > > That's very interesting, which JS library are you using for JSON-RPC calls > from ExtJS? > Or does ExtJS provide JSON-RPC calls out of the box? >
No, it is regretful that ExtJS (at least 2.0.1 which I am using) doesn't function well with z3c.jsonrpc out of the box, because z3c.jsonrpc is expecting a content type 'application/json' while the default json implementation of that of ExtJS sends out 'application/x-www-form-urlencoded'. So I use a slightly customized version which overrides several functions of the default Ext.lib.Ajax, especially the request method, to add the required header. Ext.lib.Ajax.asyncRequest = function(method, uri, callback, postData, async){ var o = this.getConnectionObject(); if (!o) { return null; } else { o.conn.open(method, uri, async); if (this.useDefaultXhrHeader) { if (!this.defaultHeaders['X-Requested-With']) { this.initHeader('X-Requested-With', this.defaultXhrHeader, true); } } if(postData && this.useDefaultHeader && (this.headers['Content-Type']===undefined)){ this.initHeader('Content-Type', this.defaultPostHeader); } if (this.hasDefaultHeaders || this.hasHeaders) { this.setHeader(o); } this.handleReadyState(o, callback); o.conn.send(postData || null); return o; } }; Ext.lib.Ajax.request = function(method, uri, cb, data, options) { if(options){ var hs = options.headers; if(hs){ for(var h in hs){ if(hs.hasOwnProperty(h)){ this.initHeader(h, hs[h], false); } } } if(options.xmlData){ this.initHeader('Content-Type', 'text/xml', false); method = 'POST'; data = options.xmlData; }else if(options.jsonData){ this.headers['Content-Type'] = 'application/json'; this.hasHeaders = true; method = 'POST'; data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData; } } var async = (options.async === false) ? false : true; return this.asyncRequest(method, uri, cb, data, async); }; I made a report of this to the ExtJS folks. And the source code of the most recent version 2.2 now has 'application/json' in the request method. I suppose it should be working out of box now, although I am still using the old version. -- Hong Yuan 大管家网上建材超市 装修装潢建材一站式购物 http://www.homemaster.cn _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users