I'm trying to set up a web page which fires off a number of
simultaneous requests, and displays the results as they come in. Here's
my (very simple) attempt to do this, using loadJSONDoc. Basically, I
have a function which uses document.write (a hack for now, I know...)
to write out a placeholder span. Then it fires off a loadJSONDoc
request to get data from a CGI, with a callback to fill in the
placeholder.

When I run this with a couple of placeholders, the data gets refreshed
fine, but it seems that only one request is run at a time. Looking at
the processes on the box, one CGI starts up, but the second doesn't
start until the first is complete.

It looks like *something* is serialising my requests - precisely what I
don't want. What am I doing wrong?

Thanks,
Paul.

PS I can't afford to serialise, as my real app will have anything
between 50 and 100 such "delayed spans". I don't need to worry about
the load on my server, it's a lightly loaded intranet so 50-100
simultaneous CGIs won't kill it :-)

---- Sample code ----
<html>
<head>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script>
var id = 0;

function delayedSPAN(url, args, template) {
    var d = loadJSONDoc(url, args);
    var this_id = "delayedSPAN" + id;
    id = id + 1;
    document.write('<span id="' + this_id + '">Placeholder</span>');
    var gotData = function(data) {
        text = template.replace(/\{(\w+)\}/g,
                function (str, name) {
                    return data[name];
                });
        sp = SPAN(text);
        swapDOM(this_id, sp);
    };
    var getFailed = function(err) {
        alert("Failed to get data!");
    };
    d.addCallbacks(gotData, getFailed);
}
</script>
<title>A MochiKit demo</title>
</head>
<body>
    We get the duration:<br>
    <script>delayedSPAN("/cgi-bin/test.py", {}, "Dur:
{duration}");</script>
    <br>
    <script>delayedSPAN("/cgi-bin/test.py", {}, "Second:
{duration}");</script>
    <br>
    in seconds.
    <script>
    </script>
</body>
</html>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to