On 08/23/2010 11:53 AM, Claus Straube wrote: > Hi Martin, > > I got the problem, but I've no solution yet (okay - a possible > workaround, but not really a solution ;) > > the playground stuff works with the file you provided, because they are > on the same server. If I deploy my code on a server and will call a json > file (it doesn't matter, if it's your's or mine) that is lying on the > same machine it works as well. > > I found in Nabble [1] something like ...setCrossDomain(true); Can I > configure this anywhere? Or an other question - the twitter sample you > provided on the qooxdoo page works locally and I'm sending definitely a > request to an external server. The difference is qx.data.store.Json and > qx.data.store.Jsonp (is that so?). I'm using qx.data.store.Json because > I didn't get 100% what is qx.data.store.Jsonp good for and what I have > to do on server side... If qx.data.store.Jsonp is the solution I have to > go deeper in it. Is this the solution?
That's exactly right: For cross-domain requests you need to use JsonP. If I understand it right this will automatically chose the script transport, which works cross-domain. So you don't have to add any more configuration to the qx.data.store.Jsonp object. JSONP in general does not just return a Json structure. A Json structure alone, if loaded as a <script> in the browser, would just create a momentary data item in the browser runtime that is immediately gone. So you have to wrap it up in some JS code that gives it permanence, the simplest way of doing that being prefixing the Json data with something like "var a = ". As the server cannot easily know what kind of wrapping would be suitable for the client (variable "a" might already be in use), it allows the client to provide the wrapping code as well, so it can chose how to get at the Json data. The JsonP data store takes care of all this wrapping and unwrapping, all you have to provide is the name of the server's URL parameter (the third parameter in the Jsonp constructor [1]), so it can pass the correct value. And yes, the server has to support this, as it has to apply the wrapping. To read up on JSONP take a look at [2]. T. [1] http://demo.qooxdoo.org/current/apiviewer/#qx.data.store.Jsonp [2] http://ajaxian.com/archives/jsonp-json-with-padding > > Best regards - Claus > > > [1] > http://old.nabble.com/using-a-plain-json-file-as-table-data-td25889134.html > > > Am Montag, den 23.08.2010, 11:13 +0200 schrieb Martin Wittemann: >> Hey, >> >> did you try it in your application of in the playground? I used the >> playground which is loaded via http and it worked. So maybe you should load >> you application from a server and give it a try. Additionally, try another >> borwser sometimes the browsers are very restrictive with loading data. >> >> Best, >> Martin >> >> Am 23.08.2010 um 10:05 schrieb Claus Straube: >> >>> Hi Martin, >>> >>> thank you for your answer. I've tested your url: >>> >>> --snip-- >>> /* >>> >>> ------------------------------------------------------------------------- >>> Below is your actual application code... >>> >>> ------------------------------------------------------------------------- >>> */ >>> var url = >>> "http://demo.qooxdoo.org/devel/demobrowser/demo/data/json/list.json"; >>> this.debug("setting url --> " + url); >>> >>> var jsonStore = new qx.data.store.Json(url); >>> >>> this.debug("store --> " + jsonStore); >>> this.debug("store state --> " + jsonStore.getState()); >>> this.debug("model --> " + jsonStore.getModel()); >>> >>> jsonStore.addListener("loaded", function(e) >>> { >>> >>> this.debug("model has been loaded --> " + e); >>> // model is created at this point >>> // and the data of the given event ('e' parameter) >>> // is the created model >>> var model = e.getData(); >>> this.doSomethingWithTheModel(model); >>> }, this); >>> }, >>> >>> doSomethingWithTheModel: function(model){ >>> this.debug("method 'doSomethingWithTheModel' called with model --> " + >>> model); >>> alert("model loaded --> " + model); >>> } >>> --snip-- >>> >>> the result was: >>> >>> 001144 qx.core.Init: Load runtime: 1144ms >>> 001155 remote_test.Application[15]: setting url --> >>> http://demo.qooxdoo.org/devel/demobrowser/demo/data/json/list.json >>> 001172 remote_test.Application[15]: store --> qx.data.store.Json[40] >>> 001174 remote_test.Application[15]: store state --> queued >>> 001175 remote_test.Application[15]: model --> null >>> 001176 qx.core.Init: Main runtime: 30ms >>> 001185 qx.core.Init: Finalize runtime: 7ms >>> 001210 qx.io.remote.Exchange: Unknown status code: 0 (4) >>> >>> So it worked not for me with the provided url (status code is here 0 as >>> well and the json file should be ok...). The code execution seems for me >>> quite fast for downloading something from the web. Does the json store >>> block the application while downloading a resource? Any other hints that >>> I can try to get it running? >>> >>> Best regards and thanks in advance - Claus >>> >>> >>> >>> >>> Am Montag, den 23.08.2010, 08:54 +0200 schrieb Martin Wittemann: >>>> Hey, >>>> >>>>> --snip-- >>>>> var url = "http://www.catify.com/demo/json/dummy.json"; >>>>> var jsonStore = new qx.data.store.Json(url); >>>>> jsonStore.addListener("loaded", function(e) >>>>> { >>>>> // model is created at this point >>>>> // and the data of the given event ('e' parameter) >>>>> // is the created model >>>>> this.doSomethingWithTheModel(e.getData()); >>>>> }, this); >>>>> }, >>>>> >>>>> doSomethingWithTheModel: function(model){ >>>>> alert(model); >>>>> } >>>>> --snip-- >>>>> >>>>> The json document is really simple, too: >>>>> { >>>>> foo: "foo", >>>>> bar: "bar" >>>>> } >>>> >>>> You code seems to work. I tried it in the qooxdoo playground to see whats >>>> wrong. As i said, the code itself is ok. The problem is the JSON file or >>>> the status code returned by the server (0) delivering the JSON file. Thats >>>> the reason out transport layer doesn't do anything with the data. Using >>>> foe example another URL [1] brings you the desired result. >>>> >>>> Regards, >>>> Martin >>>> >>>> [1] http://demo.qooxdoo.org/devel/demobrowser/demo/data/json/list.json >>> >>> >>> -- >>> claus straube >>> >>> phone +49-89-1265-3103 >>> mobile +49-176-49673717 >>> skype clausstraube >>> web http://www.catify.com >>> office room 1.122, heßstr. 89, 80797 munich >>> <smime.p7s><ATT00001..txt><ATT00002..txt> >> >> > > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > > > > _______________________________________________ > qooxdoo-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel ------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
