This project is archived and is in readonly mode.

#878 ✓invalid
Bogdan Gusiev

Request onSuccess API problem

Reported by Bogdan Gusiev | April 9th, 2010 @ 09:48 PM

I am building an advanced widgets library based on mootools to meet the needs of the application we are working on.
One of the problem I face with is that the code that is doing XHR is not reusable because it should always know about the response Content-Type.
Mootools has a lot of classes for doing XHR. But not all of the cases are covered.
For instance Form.Request that suppose to return JSON.

Currently I have make generic Request in reusable code and convert response text to json/html/js every time I use this code.

Request#response property is something that might help, but it is not as good as it should be. And it is not documented at all.
I think that response should be an object that transform response text to any format: json, xml, html, text etc, extract javascript from html and so on.

new Request(
... onSuccess: function() {
this.response.toHtml() or toJson() or toXml() } ...); or even in this way:
function(response) { ...}

Tell me guys, what do you think?

Thanks, Bogdan.

Comments and changes to this ticket

  • Tim Wienk

    Tim Wienk April 9th, 2010 @ 11:23 PM

    Aren't those functions already there?

    JSON.decode(response); // in -core
    Elements.from(response); // in -more
    
  • Bogdan Gusiev

    Bogdan Gusiev April 9th, 2010 @ 11:32 PM

    Yes, they are here. Problem is that response is not accessible as text in the case of Form.Request.

  • Fábio M. Costa

    Fábio M. Costa April 10th, 2010 @ 03:02 AM

    • State changed from “new” to “invalid”

    I liked your idea but this is something to be discussed on the mailing list or on IRC, wanna join us?
    We are rethinking about the way the request object works right now. On 2.0 it will be "intelligent".
    Thanks for helping with the idea.

    I'm settings this as invalid since this is something to be discussed not a bug, don't take me wrong.

    IRC: irc://irc.freenode.net/#mootools
    MAILING LIST: http://groups.google.com/group/mootools-users

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages