Hi Andrés,

You need to send a request from your GWT app to the PHP script via a
requestbuilder


       final RequestBuilder builder = new
RequestBuilder(RequestBuilder.POST, url);
       builder.setHeader("Content-Type",
"application/x-www-form-urlencoded");
       try
       {
           builder.sendRequest(parms, callback);
       }
       catch (final RequestException e)
       {
           submissionError(url, e);
       }

In your PHP code, return the database results as JSON

      die(urlencode(json_encode($data)));

Back in the GWT app, in the callback routine, extract the data. There are
loads of checks you might like to do before this (check for a valid return
and not a PHP script error, for example).


        final String decodedText = URL.decodeComponent(responseText);

        try
        {
            data = JSONParser.parse(decodedText).isObject();
        }
        catch (final Exception e)
        {
            // Error code here
        }

And then check that you got back what you expected. In the data, you might
like to always return a status and check if the script completed
successfully. Mine include

success - completed correctly, no message
message - completed correctly with a message for the user
warning - script did not complete as expected - message for the user (e.g.
search returned no results, login failed, etc)
error - script caught a *real*error - SQL error etc.

but I have others

Ian

http://examples.roughian.com



2009/6/5 ANDRES BRUN <[email protected]>:
> Hello Everybody
> I'm trying to implement a code that permit me integrate PHP, GWT, MYSQL, I
> was testing and implementing different examples but I don't understand
> really good, which is the correct way to send data with JSON and
> principally. How I can receive that data in GWT? Please, I'm not newbie in
> Programation but I'm really newbie in GWT, and this version 1.6 is really
> difficult to learn. Somebody can help me with a good example "for
> dummies"... jajaja.
> Thank you
> --
> Andrés Brun
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to