finally I got the solution:

(function () {
 var success = Request.JSON.prototype.success;
Request.JSON.prototype.success = function (text) {
 try { success.bind(this)(text); }
 catch(e) {
 this.onFailure(e);
throw e;
}
}
})();


On Mon, May 25, 2009 at 2:52 AM, nutron <[email protected]> wrote:

> The important thing is that the Core is designed to provide you the tools
> to do what you need, not to add as much flexibility as possible for all use
> cases. Your use case is the edge case (Request.HTML is used 99% of the time
> to update the DOM with HTML fetched from the server). Even though your case
> is an edge case, there's an easy way to manage it: don't have the class
> evaluate the scripts and then do it when it fits your logic flow.
>
> 2009/5/24 Fábio Costa (via Nabble) 
> <ml-user%2b98816-1760363...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967576&i=0>
> >
>
>> Thats cool, but why not increase flexibility if it is something that makes
>> sense?
>> And another thing that should be discussed is the request.HTML sometime
>> you dont need all of its functions, some times you just need the response
>> text and the javascript for example... i thought that there could be options
>> to set what response you want to get... ust some thoughts...
>>
>> Fábio Miranda Costa
>> Engenheiro de Computação
>> http://meiocodigo.com
>>
>>
>> On Sun, May 24, 2009 at 9:03 PM, Aaron Newton 
>> <anut...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=0>
>> > wrote:
>>
>>>
>>> Catching poorly formatted JSON would require parsing the JSON string
>>> before evaluating it, which means basically making a JS parser for
>>> MooTools, which I think is overkill. It's your job to return well
>>> formatted JSON.
>>>
>>> As for when scripts are evaluated (which started this thread), the
>>> best way to do this is to set evalScripts to false, then add your
>>> onSuccess logic as an event and call $exec(javascript) like so:
>>>
>>> var r = new Requst.HTML({
>>>   ...various options...
>>>   evalScripts: false,
>>>   onSuccess: function(tree, elements, html, js) {
>>>     ...your operations
>>>     $exec(js);
>>>   }
>>> });
>>>
>>>
>>> On May 23, 6:35 am, fabiomcosta 
>>> <fabiomco...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=1>>
>>> wrote:
>>> > Thierry,
>>> >
>>> > i think its impossible to catch the error on the script evaluation
>>> > because of the current method of evaluating globally the scripts.
>>> > But maybe someone has a solution...
>>> >
>>> > On May 22, 3:46 pm, Fábio Costa 
>>> > <fabiomco...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=2>>
>>> wrote:
>>> >
>>> > > Could be really useful too!
>>> > > And i think that the onException is not that useful, i would like to
>>> know if
>>> > > anybody have ever used it...
>>> > > I mean, its your headers, you are setting them... why should they
>>> return
>>> > > errors?
>>> > > I don't see why i need this but if someone have ever used or needed
>>> it
>>> > > please report...
>>> >
>>> > > Fábio Miranda Costa
>>> > > Engenheiro de Computaçãohttp://meiocodigo.com
>>> >
>>> > > On Fri, May 22, 2009 at 3:14 PM, Thierry bela nanga 
>>> > > <bna...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=3>
>>> >wrote:
>>> >
>>> > > > exactly,
>>> > > > if an error occur, there is not really a way to handle it.
>>> >
>>> > > > 2009/5/22 Fábio Costa 
>>> > > > <fabiomco...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=4>
>>> >
>>> >
>>> > > >> You mean like when the evaluation of the response gets an error,
>>> right?
>>> >
>>> > > >> Fábio Miranda Costa
>>> > > >> Engenheiro de Computação
>>> > > >>http://meiocodigo.com
>>> >
>>> > > >> On Fri, May 22, 2009 at 2:44 PM, Thierry bela nanga 
>>> > > >> <bna...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=5>
>>> >wrote:
>>> >
>>> > > >>> I want to be able to handle error when mootools evaluate the
>>> response
>>> > > >>> in Request.JSON.success, not only when the request is being done,
>>> > > >>> oherwise the overlay remains on the page and the only thing to do
>>> is to
>>> > > >>> reload the page :(
>>> >
>>> > > >>> 2009/5/22 Fábio Costa 
>>> > > >>> <fabiomco...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=6>
>>> >
>>> >
>>> > > >>>> But the onFailure is fired when an error occurs on the request,
>>> i don't
>>> > > >>>> get your point.... :S
>>> >
>>> > > >>>> Fábio Miranda Costa
>>> > > >>>> Engenheiro de Computação
>>> > > >>>>http://meiocodigo.com
>>> >
>>> > > >>>> On Fri, May 22, 2009 at 10:50 AM, Thierry bela nanga <
>>> bna...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=7>
>>> >wrote:
>>> >
>>> > > >>>>> I'll add something to this,
>>> > > >>>>> I'm using Request.JSON to send data, if the request uses POST,
>>> then I
>>> > > >>>>> recover the page with a blocking overlay that should be removed
>>> at the end
>>> > > >>>>> of the request.
>>> >
>>> > > >>>>> when en error occurs while evaluating the response in
>>> > > >>>>> Request.JSON.success, I have no way to handle it and the user
>>> only have to
>>> > > >>>>> press F5 to get out of that situation
>>> >
>>> > > >>>>> I think propose the onFailure event should be fired there
>>> >
>>> > > >>>>> 2009/5/22 Fábio Costa 
>>> > > >>>>> <fabiomco...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2967534&i=8>
>>> >
>>> >
>>> > > >>>>>  Don't you guys think that the scripts inside the HTML request
>>> should
>>> > > >>>>>> be evaluated after the onSuccess and onComplete events?
>>> > > >>>>>> Im asking this because sometimes i need the HTML inside the
>>> received
>>> > > >>>>>> response to be inject in the DOM before actually evaluating
>>> the script tags
>>> > > >>>>>> into the response.
>>> >
>>> > > >>>>>> evalScripts could be a string like 'after' and 'before', and
>>> of
>>> > > >>>>>> course, for backwards compatibility, if you put true it would
>>> eval the
>>> > > >>>>>> script before the onComplete and onSuccess events.
>>> >
>>> > > >>>>>> Fábio Miranda Costa
>>> > > >>>>>> Engenheiro de Computação
>>> > > >>>>>>http://meiocodigo.com
>>> >
>>> > > >>>>> --
>>> > > >>>>> fax : (+33) 08 26 51 94 51
>>> >
>>> > > >>> --
>>> > > >>> fax : (+33) 08 26 51 94 51
>>> >
>>> > > > --
>>> > > > fax : (+33) 08 26 51 94 51
>>> >
>>> >
>>>
>>
>>
> The MooTools Tutorial: www.mootorial.com Clientcide: www.clientcide.com
>
> ------------------------------
> View this message in context: Re: [Moo] Re: Request and 
> evalScripts<http://n2.nabble.com/-Moo--Request-and-evalScripts-tp2957436p2967576.html>
> Sent from the MooTools Users mailing list 
> archive<http://n2.nabble.com/MooTools-Users-f660466.html>at Nabble.com.
>



-- 
fax : (+33) 08 26 51 94 51

Reply via email to