Hi, In asynchronous mode, the html element is automaticaly filled In synchronous mode, it's not the case. How to get the XML response in synchronous mode? Francillo
on 12.06.2006 10:20
on 13.06.2006 09:15
Ok, I have modified the prototype and rico lib to have an XMLDocument reponse in this case. Francillo
on 24.07.2006 12:29
Yes, how did you do this ? It would be very helpfull to the comunity to have access at such functionality. Thank you,
on 14.12.2006 08:17
I also had this problem, while tweaking the code and I came up with this patch that has worked for me quite well, it is a patch for Prototype 1.4.0 that fixes the problem not just for openRico but for many others implementations, I posted some examples on my blog: http://blog.guillermoamaral.com/2006/12/14/openrico-and-synchronous-requests/ For example: ajaxEngine.sendRequest( 'transport', { asynchronous: false, parameters: 'id=1' } ); This call will work just like any other asynchronous request with this patch. How to run patch: $ patch -p0 <prototype-1.4.0-sync.diff Run in the same directory as prototype-1.4.0.js. Hope this helps, Cheers
on 11.10.2007 13:00
ok, I see the bug in prototype that assumes that you'll never need a
handle on the response object if your ajax request is synchronous, but
there's an easy way to patch rico to handle it.
The idea is that Ajax shouldn't have to trigger events when the request
is synchronous because it expects you to know when its over... But the
problem is that without the event, there is essentially no response. We
can trigger the onComplete event handling, passing in the
Ajax.Request.transport manually pretty easily, though. In the
sendRequestWithData function, just modify it to be the following (note,
I'm using Rico 1.1.1 here):
<code>
sendRequestWithData: function(requestName, xmlDocument, options) {
var requestURL = this.requestURLS[requestName];
if ( requestURL == null )
return;
// Allow for backwards Compatibility
if ( arguments.length >= 3 )
if (typeof arguments[2] == 'string')
options.parameters = this._createQueryString(arguments, 2);
/**
* @author plucas
* Added to support response handling on synchronous calls
*/
//new Ajax.Request(requestURL,
this._requestOptions(options,xmlDocument));
var ajaxRequest = new Ajax.Request(requestURL,
this._requestOptions(options,xmlDocument));
if(!options.asynchronous){
this._onRequestComplete(ajaxRequest.transport);
}
},
</code>
Happy programming!
on 15.10.2007 20:05
there's a minor bug in the code above :), use this code instead:
sendRequestWithData: function(requestName, xmlDocument, options) {
var requestURL = this.requestURLS[requestName];
if ( requestURL == null )
return;
// Allow for backwards Compatibility
if ( arguments.length >= 3 )
if (typeof arguments[2] == 'string')
options.parameters = this._createQueryString(arguments, 2);
/**
* @author plucas
* Added to support response handling on synchronous calls
*/
//new Ajax.Request(requestURL,
this._requestOptions(options,xmlDocument));
var ajaxRequest = new Ajax.Request(requestURL,
this._requestOptions(options,xmlDocument));
if(options.asynchronous == false){
this._onRequestComplete(ajaxRequest.transport);
}
},
on 20.12.2007 00:02
Question: Is this an acceptable implementation:
ajaxEngine.sendRequest( ricoAction, { asynchronous: false, method:
'post', parameters: postBody, onSuccess: callBackFunction} );
... for the purposes getting the HTTP response to "callBackFunction" so
that "callBackFunction" can utilize it ...
???
Thanks,
-Robin


