Well the doc suggests
<http://php.net/manual/fr/function.json-encode.php>that json_encode
doesn't change the variable passed as a parameter but
returns the encoded string so you've got to do something like this :
echo json_encode($tweets);

To get a jason encoded serialisation of your data output in the response and
not :
json_encode($tweets);
echo $tweets;

Which would only output $tweets not encoded.

Though if it doesn't work like I tell you, you'd better worry about
something else and I don't know exactly what at this point.

Michel Belleville


2009/11/8 ArnieML <arnie.lapi...@gmail.com>

> Hi Michel,
>
> I added the following statement after json encoding:
>
> echo $tweets;
>
> to the PHP, but the callback function still isn't getting called.
>
> Any other ideas?
>
> Thanks for the help.
>
> On Nov 7, 11:20 pm, Michel Belleville <michel.bellevi...@gmail.com>
> wrote:
> > It's been a long time since my last PHP days but shouldn't you echo or
> print
> > something to get it sent ? It seems you'd get an empty response here
> (unless
> > json_encode already outputs the answer to the response). And as you
> expect
> > at least a bit of json to run through and output parts of, your callback
> may
> > be called but not do anything about the empty response.
> >
> > Hope it helps.
> >
> > Michel Belleville
> >
> > 2009/11/8 ArnieML <arnie.lapi...@gmail.com>
> >
> > > Hello, I hope someone can help. I'm issuing the following ajax jquery
> > > call:
> >
> > >        $.get("/ajaxtest.php", { ajax: "true", east: northEast.lng(),
> west:
> > > southWest.lng(), north: northEast.lat(), south: southWest.lat(), mood:
> > > amood },
> > >        function (data) {
> > >                for(var i=0; i<data.length; i++){
> > >                alert("now processing tweets");
> > >                display_tmmmarker(map, data[i], i);
> > >                }
> > >                $("#gettingtweets").remove();
> >
> > >        }, 'json');
> >
> > > The PHP page looks like this:
> >
> > > if ( $_REQUEST['ajax'] == 'true' ) {
> > >        $east   = $_REQUEST['east'];
> > >        $south  = $_REQUEST['south'];
> > >        $west   = $_REQUEST['west'];
> > >        $north  = $_REQUEST['north'];
> > >        $mood   = $_REQUEST['mood'];
> >
> > >        $tweets = get_tmmtweets($east, $south, $west, $north, $mood);
> >
> > >        json_encode($tweets);
> > >        }
> > > exit;
> >
> > > I have verified that the $tweets array has been JSON-encoded using
> > > array_values. But the callback function isn't being invoked. I put in
> > > an alert statement in the callback to verify if the function has been
> > > called, but I'm not getting the alert message. Is the $tweets array
> > > not being passed on for some reason?
> >
> > > Can someone help out? Thanks very much!
>

Reply via email to