On Sun, Sep 6, 2009 at 19:21, Matthew Curry <[email protected]> wrote:
> Thanks for your response, tsmiller.
>
> Okay, I guess I had that wrong in the code. Not sure why there are
> two flavors of Request methods, but I'll stick to qx.io.remote.Request
> for now.
>
> But unfortunately, it still doesn't work. I added a event handler for
> the 'failed', 'aborted', and 'timeout' events, and sure enough, it
> timed out. I'm not really sure why. Here is the request code now:
>
> var req = new
> qx.io.remote.Request("http://localhost:4242/getfeeds", "GET",
> "text/plain");
> req.setCrossDomain(true);
> req.addListener("completed", function(e) {
> composite.add(new qx.ui.basic.Label("getfeeds
> request completed"));
> alert(e.getContent());
> });
> req.addListener("receiving", function(e) {
> composite.add(new qx.ui.basic.Label("getfeeds
> request getting data"));
> });
> req.addListener("aborted", function(e) {
> composite.add(new qx.ui.basic.Label("getfeeds
> request aborted"));
> });
> req.addListener("timeout", function(e) {
> composite.add(new qx.ui.basic.Label("getfeeds
> request timed out"));
> });
> req.addListener("failed", function(e) {
> composite.add(new qx.ui.basic.Label("getfeeds
> request had an error"));
> });
> req.send();
>
>
> I had set cross domain, because I'm working from the filesystem, and I
> guess 'localhost' counts as a different domain.
>
> So I get the timeout result, and I never even got the 'receiving'
> event. why would that be? The server does send data.
>
>
Hi Matt,
I have a few comments.
1. I recommend that you either configure your local (development machine)
web server so that requests to localhost serve files from your qooxdoo
working directory (preferred), or move your development tree into wherever
your web server is configured to serve files from. If you're using apache2,
you might add the following stanza to
/etc/apache2/sites-enabled/000-default:
<VirtualHost 127.0.0.1>
ServerAdmin webmas...@localhost
DocumentRoot /home/matt/
<Directory /home/matt/>
Options FollowSymLinks
AllowOverride None
Order Allow,Deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
This serves all localhost requests from /home/matt, but still serves
requests to your external IP address from wherever else it's configured.
Doing this allows you to request your application via
http://localhost/path/relative/to/home/matt which allows you to also use
non-cross-domain requests from within your application.
2. If you do use cross-domain, you need to recognize that the server must
respond with different data than it does with non-cross-domain requests. A
cross-domain request uses "script transport" which issues a request using a
<script> tag. Since the response of a <script> tag is javascript executable
statements, not JSON, you must tell qooxdoo, from within the response, that
it now has a response. You do that by having your server respond with a
function call:
qx.io.remote.transport.Script._requestFinished(id, content)
See the documentation for qx.io.remote in the API viewer, or in
source/class/qx/io/remote/__init__.js
The reason you're getting your timeout is that you're never calling
_requestFinished().
Note that cross-domain requests are often dangerous so should generally not
be used in production code... and for development, you're better off using
the same code that you want for production, so configuring for localhost
development as described above is almost certainly your better option.
Cheers,
Derrell
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel