the first argument in your onSuccess IS the json object. which means
you could do this:

onSuccess: function(json){
                alert(json.Zone); // should alert "Hekla"
                alert(json.Gemeente); // should alert "Hove"

it couldn't be any easier! ;)

On Sep 10, 12:07 pm, Janec <[EMAIL PROTECTED]> wrote:
> Hello,
>
> First: sorry for my crappy English
> Second: Thanks to the mootools developers for the great framework
> Third: the problem
>
> I've been trying to get Request.JSON to work but I can't acces the
> returned object (using wamp on win xp with firefox). What am I doing
> wrong? Thanks in advance for any help. (I 've been searching fa lot
> for an answer and have tried a lot of things -> the collection of
> alerts)
>
> ////////////////////// the javascript code: ////////////////
> function laden(turl){
>  var jsonRequest = new Request.JSON({url: turl,
>         onComplete: function(results){
>                 var resulta = JSON.decode(results);
>                 //alert(resulta[0]); //resulta is null
>                 alert(results); //alerts: [object Object]
>                 alert(results.Gemeente); //alerts: undefined
>                 alert(this.xhr); // alerts: [object XMLHttpRequest]
>                 alert("test");
>         },
>         onSuccess: function(responseText, responseXML){
>                 alert(responseText); //alerts: [object Object]
>                 alert(responseXML); //alerts:  {"gemeentes":
> [{"Id":"359","Zone":"Hekla","Postcode":"2540","Gemeente":"Hove"}]}
>                 alert(this.xhr.responseText); // alerts: {"gemeentes":
> [{"Id":"359","Zone":"Hekla","Postcode":"2540","Gemeente":"Hove"}]}
>                 var resulta = JSON.decode(responseXML);
>                 alert(resulta.Gemeente); //alerts undefined
>         alert("end of alerts");
>         },
>         "secure": "false"}).get({'postcode':'2540'});
>
> };
>
> //////////////////////// the json output by the php
> file: //////////////////
> {"gemeentes":
> [{"Id":"359","Zone":"Hekla","Postcode":"2540","Gemeente":"Hove"}]}
>
> //////////////////////////

Reply via email to