Ugh... I had a lot of typos there. Excuse me as I drink my morning coffee here :)
On Wed, Jan 28, 2009 at 9:16 AM, Ryan Gahl <ryan.g...@gmail.com> wrote: > More specifically, make sure it returns javascript (not just the data), and > uses on of those content types... > > There is a pattern that should cover your needs, call JSONP (JSON with > padding), Google "jsonp" for more info. Basically, you have your server > endpoint setup to return json data (as normal), but then add a check for a > querystring parameter called something like "jsonp". The value of that > parameter then becomes the name of a function call that the server wraps the > json data in. > > So, a normal request to http://localhost/somePage > > returns json: > > {"foo": "bar"} > > But adding the jspnp parameter to the request ( > http://localhost/somePage?jsonp=someFunction) > > returns javascript+json... > > someFunction({"foo": "bar"}); > > > Note that this requires the "someFunction" function to be at the global > scope level. > > There are many ways to skin this cat, really. JSONP is one of the simpler > examples. > > > > > On Wed, Jan 28, 2009 at 8:47 AM, Gabriel Gilini <gabr...@usosim.com.br>wrote: > >> Just make sure that your server returns data with one of the following >> content-types: application/ecmascript, application/javascript, >> application/x-ecmascript, application/x-javascript, text/ecmascript, >> text/javascript, text/x-ecmascript, or text/x-javascript >> as explained in the API: http://www.prototypejs.org/api/ajax/options >> >> Gabriel Gilini >> >> www.usosim.com.br >> gabr...@usosim.com.br >> gabr...@souagil.com.br >> >> >> >> On Wed, Jan 28, 2009 at 12:34 PM, Richard Quadling < >> rquadl...@googlemail.com> wrote: >> >>> >>> Hi. >>> >>> Currently I use AJAX to send POST requests and receive JSON encoded >>> data which is magically supplied as an object to me by Prototype in >>> the onSuccess handler. >>> >>> I can then examine the data and process it as I need to. >>> >>> So far so good. >>> >>> I now need to do something I don't know how to do. >>> >>> The "processing" I mentioned above is essentially a switch statement >>> which determines the processing I want. The specific case then >>> extracts the parameters from the JSON object and calls the appropriate >>> method/function with the extracted params. More functionality means >>> more editing of this 1 function. >>> >>> What I want to achieve is a way to have my server supply the call that >>> is to be made and when the response arrives at the client, it is just >>> executed, without me having to decode it first. >>> >>> I want to have a shrink wrapped set of classes which are communicated >>> with, essentially by the server. >>> >>> A simplistic example. >>> >>> Client performs some user interface action (clicks a button, drop down, >>> etc.). >>> This initiates an AJAX call to get some data. >>> The server responds with the data using JSON. >>> The onSuccess handler decodes the data client side and calls the >>> appropriate functions to handle the response. >>> >>> I want this to become >>> >>> Client performs some user interface action (clicks a button, drop down, >>> etc.). >>> This initiates an AJAX call to get some data. >>> The server responds with the data using JSON and the code required to >>> handle the data. >>> The onSuccess handler just runs the code. >>> >>> This will allow me to incrementally add functionality to the client as >>> they move around the site. >>> >>> Regards, >>> >>> Richard Quadling. >>> >>> >>> >>> >>> >>> -- >>> ----- >>> Richard Quadling >>> Zend Certified Engineer : >>> http://zend.com/zce.php?c=ZEND002498&r=213474731 >>> "Standing on the shoulders of some very clever giants!" >>> >>> >>> >> >> >> >> > > > -- > Ryan Gahl > CEO > Nth Penguin, LLC > http://www.nthpenguin.com > -- > WebWidgetry.com / MashupStudio.com > Future Home of the World's First Complete Web Platform > -- > Inquire: 1-920-574-2218 > Blog: http://www.someElement.com > LinkedIn Profile: http://www.linkedin.com/in/ryangahl > -- Ryan Gahl CEO Nth Penguin, LLC http://www.nthpenguin.com -- WebWidgetry.com / MashupStudio.com Future Home of the World's First Complete Web Platform -- Inquire: 1-920-574-2218 Blog: http://www.someElement.com LinkedIn Profile: http://www.linkedin.com/in/ryangahl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---