atom feed4 messages in com.googlegroups.gwt-extRe: json php
FromSent OnAttachments
sindroideNov 9, 2009 7:28 pm 
sindroideNov 11, 2009 4:32 pm 
Stefano GargiuloNov 12, 2009 1:59 am 
Stefano GargiuloNov 12, 2009 1:59 am 
Subject:Re: json php
From:Stefano Gargiulo (rast@gmail.com)
Date:Nov 12, 2009 1:59:19 am
List:com.googlegroups.gwt-ext

what a bloodshed!!

try php json_encode instead to manually build the json string.

Stefano.

Il 12/11/2009 1.32, sindroide ha scritto:

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<sind@gmail.com> 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 gwt-@googlegroups.com. To unsubscribe from this group, send email to
gwt-ext+unsu@googlegroups.com. For more options, visit this group at
http://groups.google.com/group/gwt-ext?hl=.