[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-20 Thread Szymon Wilkołazki

Matt Foster wrote:
[...]
 
 To address the wrong order issue, you could create a queue of
 requests such that each request is asynchronous but stacked such that
 it will not be sent until the previous request has returned.  I've
 written something for this for prototype 1.5 as Ajax.RequestQueue and
 formalized this idea in my AgileAjax package in the class AjaxService.
 

I think this is not a good idea for autocompleter purposes. 
Autocompleter needs to be very fast. If you wait with next request 
until previous was completed, and, say, that previous request was 
dropped somewhere in the net, then you will wait long time, a few 
seconds at least until it will time out.

The better approach is to identify each request with some unique id, 
maybe a serial number, and check if the response you just received is 
the response for the last sent request. If the responses are 
deterministic, then parameters of request are sufficient id, if not, 
then you need a unique identifier.

I personally use Ajax.Request for this purpose. I add a serial number 
to parameters, and, at server side, I put the serial number to the 
X-JSON: header, along with status (such as error codes, if any, or 
success indicator etc). Then in the onComplete I check the header 
only. But this is only possible if you have control over serverside 
script.

I haven't any need to access the request object from the response one, 
but I always thought it was available as a parameter of the 
Ajax.Response object [1].

Richard,
As for the bug, maybe it's worth submitting the patch again to the 
Lighthouse [2], as the Trac is used no more.



1. http://prototypejs.org/api/ajax/response
2. http://prototype.lighthouseapp.com/


Best Regards,
SWilk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-20 Thread Jonny Nott

as a bonus, in the case of my problem, I don't even need to tag
requests with a uniqid or serial, as I know that I'm only interested
in responses to requests where the search string was the same as the
current form field value.

On Mar 20, 9:26 am, Szymon Wilkołazki wilkola...@gmail.com wrote:

 The better approach is to identify each request with some unique id,
 maybe a serial number, and check if the response you just received is
 the response for the last sent request. If the responses are
 deterministic, then parameters of request are sufficient id, if not,
 then you need a unique identifier.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-19 Thread Jonny Nott

I've now found a solution to this problem, as follows:

var inputControlCapturedValue = inputControl.getValue();

new Ajax.Request(xhrRequestUrl, {
method: 'get',
parameters: {
table: s_table,
column_name: s_columnName,
category: categorySelect.getValue(),
match: inputControl.getValue(),
action: 'selectgenericforeign'
},
onCreate: targetSelect.disable.bind(targetSelect),
onSuccess: (function(transport){
if (inputControlCapturedValue == 
inputControl.getValue()) {

targetSelect.update(transport.responseText);
targetSelect.enable();
}
}).bind(targetSelect)
});

The solution arrived at is seperating the Ajax.Request and
Element.update calls rather than using Ajax.Updater. The onSuccess
callback function then checks that the input box's value hasn't
changed since the request was initiated. If it has changed, it won't
bother updating the select box with its response HTML.

Thanks all for help and pointers.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-19 Thread Matt Foster

I've got to add my two cents as well,

For addressing the issue of attaching parameters to the Ajax.Request
object, they're actually available in the callbacks.  Each callback
gets sent an Ajax.Response instance which contains the request
property which in turn has the parameters property,
http://prototypejs.org/api/ajax/response

To address the wrong order issue, you could create a queue of
requests such that each request is asynchronous but stacked such that
it will not be sent until the previous request has returned.  I've
written something for this for prototype 1.5 as Ajax.RequestQueue and
formalized this idea in my AgileAjax package in the class AjaxService.

http://positionabsolute.net/blog/2007/04/ajax-request-queue.php
http://positionabsolute.net/blog/2009/03/agile-ajax.php




On Mar 19, 2:34 pm, Jonny Nott jonn...@gmail.com wrote:
 I've now found a solution to this problem, as follows:

                 var inputControlCapturedValue = inputControl.getValue();

                 new Ajax.Request(xhrRequestUrl, {
                         method: 'get',
                         parameters: {
                                 table: s_table,
                                 column_name: s_columnName,
                                 category: categorySelect.getValue(),
                                 match: inputControl.getValue(),
                                 action: 'selectgenericforeign'
                         },
                         onCreate: targetSelect.disable.bind(targetSelect),
                         onSuccess: (function(transport){
                                 if (inputControlCapturedValue == 
 inputControl.getValue()) {
                                         
 targetSelect.update(transport.responseText);
                                         targetSelect.enable();
                                 }
                         }).bind(targetSelect)
                 });

 The solution arrived at is seperating the Ajax.Request and
 Element.update calls rather than using Ajax.Updater. The onSuccess
 callback function then checks that the input box's value hasn't
 changed since the request was initiated. If it has changed, it won't
 bother updating the select box with its response HTML.

 Thanks all for help and pointers.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-11 Thread Jonny Nott

Thanks for that link Alex.

However, as I've tried to proceed with this, I keep coming back to
needing answers to my two original questions. Can anyone assist?

The questions:

- Which callback will allow me to intercept Ajax.updater at this
point? Will this even work with Ajax.updater, or do I need to use
Ajax.request and update the contents of the select box element
manually if the condition for doing so are met?
- How can a callback access the 'parameters' which were set for the
request? Can it even? Will I need to duplicate 'match' into some local
variable - and even then how will the anonymous callback function get
at it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-11 Thread Alex Mcauley

Can you report the question again as it seems to be missing

Thanks
Alex
- Original Message - 
From: Jonny Nott jonn...@gmail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Wednesday, March 11, 2009 7:57 PM
Subject: [Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing 
issue



 Thanks for that link Alex.

 However, as I've tried to proceed with this, I keep coming back to
 needing answers to my two original questions. Can anyone assist?

 The questions:

 - Which callback will allow me to intercept Ajax.updater at this
 point? Will this even work with Ajax.updater, or do I need to use
 Ajax.request and update the contents of the select box element
 manually if the condition for doing so are met?
 - How can a callback access the 'parameters' which were set for the
 request? Can it even? Will I need to duplicate 'match' into some local
 variable - and even then how will the anonymous callback function get
 at it?
 
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-11 Thread Richard Quadling

The response does not have access to the request. I created the ticket
for this a long time ago, but I can't establish if there is any
memleak when the response includes the request.

http://dev.rubyonrails.org/ticket/9691

Over a year old ticket.


2009/3/11 Jonny Nott jonn...@gmail.com:

 Thanks for that link Alex.

 However, as I've tried to proceed with this, I keep coming back to
 needing answers to my two original questions. Can anyone assist?

 The questions:

 - Which callback will allow me to intercept Ajax.updater at this
 point? Will this even work with Ajax.updater, or do I need to use
 Ajax.request and update the contents of the select box element
 manually if the condition for doing so are met?
 - How can a callback access the 'parameters' which were set for the
 request? Can it even? Will I need to duplicate 'match' into some local
 variable - and even then how will the anonymous callback function get
 at it?
 




-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
Standing on the shoulders of some very clever giants!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-11 Thread Richard Quadling

2009/3/11 Richard Quadling rquadl...@googlemail.com:
 The response does not have access to the request. I created the ticket
 for this a long time ago, but I can't establish if there is any
 memleak when the response includes the request.

 http://dev.rubyonrails.org/ticket/9691

 Over a year old ticket.


This is response to - How can a callback access the 'parameters'
which were set for the
request? Can it even?.

Typing this in the Firebug console ...

new 
Ajax.Request('http://www.prototypejs.org',{onSuccess:function(){console.debug(arguments);}})

and then looking at the console output. No reference to the request
and therefore the params.



 2009/3/11 Jonny Nott jonn...@gmail.com:

 Thanks for that link Alex.

 However, as I've tried to proceed with this, I keep coming back to
 needing answers to my two original questions. Can anyone assist?

 The questions:

 - Which callback will allow me to intercept Ajax.updater at this
 point? Will this even work with Ajax.updater, or do I need to use
 Ajax.request and update the contents of the select box element
 manually if the condition for doing so are met?
 - How can a callback access the 'parameters' which were set for the
 request? Can it even? Will I need to duplicate 'match' into some local
 variable - and even then how will the anonymous callback function get
 at it?
 




 --
 -
 Richard Quadling
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 Standing on the shoulders of some very clever giants!




-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
Standing on the shoulders of some very clever giants!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue

2009-03-02 Thread Alex Mcauley

Jonny ..

i wrote this a few months back and forgot about it ...

Its the basics you will need to achieve what you want to do 

Any questions please ask

http://proto-scripty.wikidot.com/prototype:how-to-throttle-ajax-requests

Regards
Alex


- Original Message - 
From: Alex Mcauley webmas...@thecarmarketplace.com
To: prototype-scriptaculous@googlegroups.com
Sent: Sunday, March 01, 2009 7:21 PM
Subject: [Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing 
issue



 there is a completely easier way to do what you want and save memory on 
 the
 client side and serverside ...

 If you can wait till monday i will post the code for you to do it


 Regards
 Alex

 - Original Message - 
 From: Jonny Nott jonn...@gmail.com
 To: Prototype  script.aculo.us 
 prototype-scriptaculous@googlegroups.com
 Sent: Saturday, February 28, 2009 12:12 PM
 Subject: [Proto-Scripty] Ajax.Updater home-brew autocompletion timing 
 issue



 I use the following Ajax.Updater code to auto-complete (refresh) the
 options within a select box according to text entered into an input
 [type=text].

 The code is part of a function which is envoke by the 'onkeyup' event
 on the input:

 new Ajax.Updater(targetSelect.identify(), xhrRequestUrl, {
 method: 'get',
 parameters: {
 match: inputControl.getValue()
 },
 onCreate: targetSelect.disable.bind(targetSelect),
 onSuccess: (function(){
 targetSelect.enable();
 }).bind(targetSelect)
 });

 The problem: with large data sets, the ajax requests take long time to
 process on the server, and then there's network lag, etc. This returns
 in (sometimes) the responses come back in the wrong order. An example:

 - user types 'abc', which sets off 3 requests, with 'match' param of
 'a', 'ab', 'abc' respectively.
 - due to server delay/network lag etc, sometimes the response for
 'abc' comes back *before* the 'ab'  response
 - select box ends up containing all entries match 'ab', rather than
 only those matching 'abc'

 The solution I've thought of:

 Somehow make a callback function which short-circuits (i.e. aborts)
 the Ajax.updater object if it's 'match' parameter is different from
 the current value of 'inputControl' at the point where it's about to
 empty and replenish the select box with the HTML from the response.
 Issues:

 - Which callback will allow me to intercept Ajax.updater at this
 point? Will this even work with Ajax.updater, or do I need to use
 Ajax.request and update the contents of the select box element
 manually if the condition for doing so are met?
 - How can a callback access the 'parameters' which were set for the
 request? Can it even? Will I need to duplicate 'match' into some local
 variable - and even then how will the anonymous callback function get
 at it?

 Am I barking up the wrong tree altogether?

 Jon

 



 
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---