tnx On Mon, Feb 23, 2009 at 4:12 PM, Jeremy B <[email protected]> wrote:
> it sounds like you want to use Request.JSON > http://mootools.net/docs/Request/Request.JSON > > Off the top of my head it might be something like this: > > $('myForm').addEvent('submit',function(e){ > var formData = $('myForm').toQueryString(); > var jsonRequest = new Request.JSON({ > url:'http://site.com/tellMeAge.php', > onSuccess: handleResponse > }).get(formData); > return false; > }); > > function handleResponse(json, text){ > console.log(json.data); > } > > > There is probably a better way to do this, but this should be a good > starting point. > > > Jeremy > > > > On Mon, Feb 23, 2009 at 12:57 PM, Itay Moav <[email protected]>wrote: > >> Works wonderfully, >> >> But, is there a built in way to make all results returned from an XHR >> request as valid JSON, without me using decode in several places? >> >> >> On Mon, Feb 23, 2009 at 3:51 PM, Jeremy B <[email protected]> wrote: >> >>> I believe you want to use JSON.decode(str); >>> See the docs here: >>> http://mootools.net/docs/Utilities/JSON >>> >>> Jeremy Bueler >>> www.jbueler.com >>> >>> >>> >>> On Mon, Feb 23, 2009 at 12:46 PM, Itay Moav <[email protected]>wrote: >>> >>>> Hi, >>>> >>>> I have a form submitted: >>>> Form.set('send',{'onSuccess':function(responseText, responseXML){ >>>> >>>> alert(responseText.data); >>>> >>>> } >>>> }); >>>> Form.send(); >>>> >>>> >>>> The responseText is "{'data':10}" >>>> So, what should I do (beside using an eval) to make >>>> alert(responseText.data); echo 10? >>>> Right now, it is "undefined". >>>> The request returns with the correct data. >>>> >>> >>> >> >
