3.2.0

PHP echo cells JavaScript issue

Hi, I have the following PHP code to build cells from a dataset and echo the results back to JavaScript :-

$rows2 = array();
while ($record = @mysql_fetch_row($_SESSION['dataset'])) {
$cols2 = array();
foreach ($record as $value) {
$cols2[] = '"'.addslashes($value).'"';
}
$rows2[] = "\t[".implode(",", $cols2)."]";
}
echo "[\n".implode(",\n",$rows2)."\n];\n";

And the following JavaScript processing the AW.HTTP.Request response :-

newrequest1.response = function(doc1) {
if (doc1 != '') {
cells = doc1;
rebuild_grid();
}

cells recieves the echoed results and the variable contains
[
["2654","0","06582","10-20","DRY","20.6300","2"],
["2655","0","06539","10-20","DRY","24.0680","2"],
["2656","0","06540","10-20","DRY","37.1900","2"],
["2657","0","06542","10-20","DRY","37.1900","2"],
["2658","0","06543","10-20","DRY","37.1900","2"],
["2659","0","06547","10-20","DRY","37.1900","2"],
["2660","0","00003","20-30","DRY","15.0000","2"],
["2661","0","00004","30-40","DRY","18.7500","2"]
]

Grid shows (grid.setCellText(cells);) :-

[["2654","0","06582","10-20","DRY","20.6300","2"], ["2655","0","06539","10-20","DRY","24.0680","2"], ["2656","0","06540","10-20","DRY","37.1900","2"], ["2657","0","06542","10-20","DRY","37.1900","2"], ["2658","0","06543","10-20","DRY","37.1900","2"], ["2659","0","06547","10-20","DRY","37.1900","2"], ["2660","0","00003","20-30","DRY","15.0000","2"], ["2661","0","00004","30-40","DRY","18.7500","2"]]

in every cell ?

Please advise how to resolve - Thanks in advance.
March 25,
use eval to force js to recognise format of received data. cells=eval(doc1);
t4
March 25,
That did the trick - Thank You
March 25,

This topic is archived.

See also:


Back to support forum