[Dojo-interest] json and evalJson

Umapathy S nsupathy at gmail.com
Thu Dec 7 08:43:11 MST 2006


Thanks Shane.  It seems to work fine.  I could go through the array
and print to firebug.  But the syntax error is annoying

 SyntaxError: missing ] after element list           dojo.js (line 138)

I am using dojo 0.4 and havent upgraded to 0.4.1 yet.



On 12/7/06, Shane O'Sullivan <shaneosullivan1 at gmail.com> wrote:
> As opposed to returning a JSON object containing a "data" field, try just
> returning an array, e.g.
>
> echo '[{"message":"message
> 1asdlfkjsldf","msg_date":"2006-10-24","affected_profile":"All Users"},
>         {"message":"message 2
> aslkaasdflaasdf","msg_date":"2006-11-13","affected_profile":"NULL"}
>      ]';
>
> On 07/12/06, Umapathy S <nsupathy at gmail.com> wrote:
> >
> > Hi,
> >
> > I am new to json and trying to use json with dojo.
> >
> > I have this function
> >
> > function LoadMessages() {
> >         var kw = {
> >             url: "FetchMessage.php",
> >             mimetype: "application/json",
> >             load: function(type, in_data, http) {
> >                 arrayData = dojo.json.evalJson(in_data);
> >                 console.info(arrayData.length);
> >                 console.info(arrayData[0][msg_date]);
> >             }
> >         }
> >         dojo.io.bind(kw);
> > }
> >
> > And FetchMessage.php is
> > <?php
> >     header('Content-type: text/json');
> >     echo '{"data":[{"message":"message 1
> > asdlfkjsldf","msg_date":"2006-10-24","affected_profile":"All
> > Users"},{"message":"message 2
> > aslkaasdflaasdf","msg_date":"2006-11-13","affected_profile":"NULL"}]}';
> > ?>
> >
> > In firebug console, I keep getting "SyntaxError: missing ] after
> > element list".  I tried changing  the php script like
> >
> >   echo '{"data":[{"message":"message 1
> > asdlfkjsldf","msg_date":"2006-10-24","affected_profile":"All
> > Users"},{"message":"message 2
> > aslkaasdflaasdf","msg_date":"2006-11-13","affected_profile":"NULL"}]};';
> >
> > And the error is different,  but this time SyntaxError: missing ) in
> > parenthetical.  I have tried many combinations.  The actual code gets
> > data from mysql and calls JSON php to encode (based on the dojo Tree
> > tutorial).  I thought that wasnt working with dojo.
> >
> > I have gone through the dojo jot manual and it is not helping me
> > either.  Any pointers, hints will be helpful.
> >
> > thanks
> >
> > Umapathy
> >
> > --
> > --The browser you can trust - Firefox 2
> > http://www.mozilla.com/firefox/
> > --Please say NO to nuclear weapons
> > _______________________________________________
> > Dojo FAQ: http://dojo.jot.com/FAQ
> > Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> > Dojo-interest at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> >
>
>


-- 
--The browser you can trust - Firefox 2
http://www.mozilla.com/firefox/
--Please say NO to nuclear weapons


More information about the Dojo-interest mailing list