I got it working now! Just have to add
if ($scriptTag) {
echo ');'."\n";
}
at the end of query.php.... thanks anyway
On Nov 10, 1:28 am, sindroide <[email protected]> wrote:
> hello ...recently I posted for some help with HttpProxy to perform a
> web app with php server side and gwt client side.
> My problem was that a had to use ScriptTagProxy... i didn't know that
> changing port would be another host... anyway now that i solved that
> problem i still don't get it
>
> I have two php files
> sample-proxy.php
> "<?
> $scriptTag = false;
> $callback = getRequestValue('callback');
> $sort = getRequestValue('sort');
> $dir = getRequestValue('dir');
> $start = getRequestValue('start');
> $limit = getRequestValue('limit');
>
> if ($callback !== false) {
> $scriptTag = true;
> header('Content-Type: text/javascript; charset=utf-8');
>
> }
>
> if ($scriptTag) {
> echo $callback.'(';
>
> }
>
> echo "
> {
> 'item':
> [";
>
> if ( $start == 0 )
> echo "
> {
> 'title': 'bedla'
> },
> {
> 'title': 'houba'
>
> }";
>
> echo " ]}
>
> ";
>
> if ($scriptTag) {
> echo ');'."\n";
>
> }
>
> function getRequestValue($name, $default = false)
> {
> return ( isset($_REQUEST[$name]) ? $_REQUEST[$name] : $default );}
>
> "
> wich gives this result when lunch on browser
>
> { 'item': [ { 'title': 'bedla' }, { 'title': 'houba' } ] }
>
> and query.php (without quotes at footter and top)
> "
> <?php
> require_once("JSON.php");
> $scriptTag = false;
> $callback = getRequestValue('callback');
> $sort = getRequestValue('sort');
> $dir = getRequestValue('dir');
> $start = getRequestValue('start');
> $limit = getRequestValue('limit');
>
> if ($callback !== false) {
> $scriptTag = true;
> header('Content-Type: text/javascript; charset=utf-8');
>
> }
>
> if ($scriptTag) {
> echo $callback.'(';
>
> }
>
> $conector = mysql_connect('127.0.0.1', 'root') or die(mysql_error());
> mysql_select_db('yoo') or die(mysql_error());
>
> $sqlQuery = "SELECT title, introtext FROM jos_content WHERE id in
> (1,5,8)";
> $dataReturned = mysql_query($sqlQuery) or die(mysql_error());
> $i = 0;
>
> while($row = mysql_fetch_array($dataReturned)){
>
> // We fill the $value array with the data.
> // $row = mysql_fetch_array($dataReturned);
>
> $value{'item'}{$i}{'title'}= $row['title'];
> $i++;
>
> }
>
> $json = new Services_JSON();
> $output = $json->encode($value);
> print($output);
>
> function getRequestValue($name, $default = false)
> {
> return ( isset($_REQUEST[$name]) ? $_REQUEST[$name] : $default );}
>
> ?>
> "
> wich gives this result lunching on browser
>
> { 'item': [ { 'title': 'Welcome to Joomla' }, { 'title': 'Joomla
> License Guidelines' } ] }
>
> y had to modify JSON.php to change double to simple quotes .. spaces
> etc
>
> and with this client side code
>
> ScriptTagProxy proxy = new ScriptTagProxy(
> "http://localhost/quienes/sample-proxy.php");
>
> final JsonReader jsonReader = new JsonReader(new RecordDef(
> new FieldDef[] {
> new StringFieldDef("title") }));
> jsonReader.setRoot("item");
>
> final Store store = new Store(proxy, jsonReader);
>
> the grid ... etc etc ...
> ...
> store.load();
>
> The GridPanel only fills with result using "sample-proxy.php" but not
> with query.php...
> what would be wrong???
>
> thanks a lot for your help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"GWT-Ext Developer Forum" 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/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---