[Developers] multiple mjt queries
Nick Shapiro
nick at metaweb.com
Tue Nov 6 20:47:27 UTC 2007
You could put the task inside a mjt.def function, then call the function as many times as you want.
Be careful to define the function before you call it.
For example
http://dev.mqlx.com/~nick/example.html
<div id="top" style="display:none">
<div mjt.def="getmembers(groupId)"> <!-- begin function -->
<div mjt.task="query">
mjt.mqlread({
"type":"/type/usergroup",
"id":groupId,
"member":[{
"id":null
}]
})
</div>
<div mjt.choose="query.state" mjt.strip="1">
<div mjt.when="ready" mjt.strip="1"> <!-- process results -->
<div mjt.for="member in query.result.member">
$member.id
</div>
</div>
<div mjt.when="wait" mjt.strip="1">
<div class="loadingMsg">loading report...</div>
</div>
<div mjt.when="error" mjt.strip="1">
Error
</div>
</div><!-- finish choose=query.state -->
</div> <!-- finish function -->
<div mjt.script="" mjt.strip="1">
var groups = ["/freebase/bots", "/freebase/mwstaff"];
</div>
<div mjt.for="agroup in groups">
<h1>${agroup}</h1>
${getmembers(agroup)} <!-- call function -->
</div>
</div><!-- close top div-->
----- Original Message -----
From: "Steve Sak" <ssak at appliedminds.com>
To: "For discussions about MQL, Freebase API and apps built on Freebase" <developers at freebase.com>
Sent: Tuesday, November 6, 2007 10:58:38 AM (GMT-0800) America/Los_Angeles
Subject: Re: [Developers] multiple mjt queries
I believe the problem is that I'm refreshing the pane containing the
href to the query before the query is completed which the causes brower
to cancel the in-process request. So, how do I rerun a compiled
mjt.task without reloading and calling mjt.run?
Nick Thompson wrote:
> mjt doesn't normally use xhr, so i'm puzzled by the error message.
> are you using a custom mjt.task type? it sounds like your xhr layer
> (part of dojo?) might allow only one pending request at a time.
>
> usually i just fire off lots of queries and let the browser queue them
> up in the order they are requested. i've thought about having mjt keep
> its own request queue so that you could prioritize some queries, but i
> haven't come up with a use case that would justify the complexity.
>
> nick
>
> Steve Sak wrote:
>
>> Are there any suggestions/best practices for how to run a query multiple
>> times in rapid succession with a varying parameter. I'm seeing all the
>> queries except for the last step on each other with a "Error: xhr
>> cancelled dojoType=cancel message=xhr cancelled" message. I get the
>> same behavior both when I put the parameters in a list and use mjt.for
>> to iterate and when I refresh the page the query if on multiple times.
>> Perhaps a way to vary the task id or run the query synchronously?
>>
>> Thanks
>>
>>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>
--
Steven G Sak
Applied Minds, Inc.
11718 Bowman Green Drive
Reston, Virginia 20190
o: (703) 483-2207
c: (703) 626-2557
_______________________________________________
Developers mailing list
Developers at freebase.com
http://lists.freebase.com/mailman/listinfo/developers
More information about the Developers
mailing list