[HTML_AJAX-devel] Requests and Queues

Joshua Eichorn josh at bluga.net
Wed Jul 5 10:38:59 PDT 2006


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



More information about the Html_ajax-devel mailing list