[HTML_AJAX-devel] Requests and Queues

Taiwo Femi dftaiwo at yahoo.com
Tue Jul 11 07:47:24 PDT 2006



Joshua Eichorn <josh at bluga.net> wrote: Taiwo Femi wrote:
> Hi,
> I've been really impressed with the features I've come across in 
> HTML_AJAX and have been trying it out for about a little over a week 
> now, but I'm facing a problem I'm not sure how to solve - I understand 
> that support is available for queue methods, but which/how? On my 
> site, I have a nav tree on the left which users click on and via ajax, 
> the respective content shows in the wide right hand column. Now the 
> problem is if the user clicks on A, then after a few seconds, decides 
> to click on link B, the first request is not aborted but is fully 
> carried out, then the second [B] is also fully executed. My question's 
> this - how can I abort the first request? More like how can I  do it 
> such that since the user has 'changed' his mind, there's no point in 
> returning the results of his first choice, so that it could work just 
> like the way conventional [ full reload ] browsing does. Hope my 
> question isn't too long and quite clear.....
> Thanks,
>
> Femi Taiwo.
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Html_ajax-devel mailing list
> Html_ajax-devel at lists.bluga.net
> http://lists.bluga.net/mailman/listinfo/html_ajax-devel
>   
There are a couple options to accomplish this but I think the easiest 
way to use a queue.

The queue might look something like this (not tested)

function HTML_AJAX_Queue_Single() {
}
HTML_AJAX_Queue_Single.prototype = {
    request: false,
    client: false,
    addRequest: function(request) {
        this.request = request;
    },
    processRequest: function() {
        if (this.request) {
            if (this.client) {
                this.client.abort();
            }
            this.client = HTML_AJAX.httpClient();
            this.client.request = this.request;
            this.request = false;
            this.client.makeRequest();
        }
    }
}

HTML_AJAX.queues['single'] = new HTML_AJAX_Single();

Then make a request like:
HTML_AJAX.grab('url',callback,{queue:'single'});

-josh
ps: im thinking about adding this code to the base build, so feedback on 
if it works would be good

Hi!
Sorry for not having sent a reply in almost a week  -I travelled to a remote town somewhere in Nigeria......
And thanks for the quick reply.


I tried it out, and I'll try to describe how it went
[1] First had to change

HTML_AJAX.queues['single'] = new HTML_AJAX_Single() to
HTML_AJAX.queues['single'] = new HTML_AJAX_Queue_Single();

[2]
The first thing I noticed was that it now took almost 3 times as much time as it takes without it [the single queue option] in place. 

[3]
I'm not sure at this stage what really happens, but each time the newer request [while one is currently running] is aborted. I'm not sure why since from the code, it should be the other way around......

[4]
There's also this js error thrown 

Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame :: http://libre/auto_server.php?client=all&stub=all :: anonymous :: line 1669"  data: no]

the corresponding line :

line 1669:
            this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync);

I hope this was enough information, to help understand what's really happening...

Thanks!

- femi.


 		
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates starting at 1¢/min.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://bluga.net/pipermail/html_ajax-devel/attachments/20060711/b7a2391c/attachment.html


More information about the Html_ajax-devel mailing list