Hello Peter

I use different method's.

-------------------------------
in the head of the html page:

var cTyp ={"10":["inserat",79],"20":["Banner",0]};
var cDimSets ={"r=10;":[7,14,20,30,47,49,58,66,69,70,75,77],
"r=12;":[3,9,15,16,23,24,26,29,32,33,34,35,36,37,39,40,45,46,48,52],
"r=13;":[0,25,33],
"r=15;":[1,2,4,5,6,8,10,11,12,13,17,18,19,31,38,41,44],
...
}

and then a JS-Function to parse the data and create JS-Obects
var inseratSet=new InseratSet(79,'2013-08-09 
00:00:57',3584995255,3584995255,cTyp,cDimSets);

-------------------------------
Sometimes i use for more dimensional arrays this encoding.
sport
        hockey
                Ice hockey
                Unihockey
        Skiing
                Alpine
                Nordic
                Telemark
politic
        local
        national
        international



var data='[0]sport[1]hockey[2]Ice 
hockey[2]Unihockey[1]Skiing[2]Alpine[2]Nordic[2]Telemark[0]politic[1]local[1]national[1]international'

-------------------------------

And sometimes I write all kind of data in a html object (hidden div, hidden 
field,…) and read and parse it afterwards with jquery. For the structure of 
this data, I use depending on the amount of data different ways to encode the 
data. sonetimes json, or the [0] [1] [2] method, or , as delimter for array …
<div class="dontshowme">
1,3,5,8,3
brienz,basel,bern,zürrich,luzern
</div>

-------------------------------
Or write data like this and parse it with jquery
<div id="agendaelm_51869" class="agendaelm mc mclan top2" 
data-array="red,green,blue,yellow">

-------------------------------

In one situation I need only each day  a different bigger set of js-objects, 
and create for this always a separate js-file that can be cashed in the client 
browser and then parse them to js-object when the page is loadet.
data_20130809000057.js

-------------------------------

Regards, Oliver


Am 09.08.2013 um 11:07 schrieb Peter Gutbrod:

> For a kind of single page web app, I have to populate javascript arrays with
> data from 4D arrays.
> 
> One way would be to use JSON.
> 
> But as there is no need to reload data after the initial load of the page, I
> could send the data along with the html when loading the page.
> 
> Currently I do this quick and dirty within the loop for displaying a rowset:
> 
> 
> $serEAN := ""
> while ($rs->next)
>    $row := $rs->getRow
>        $serEAN := $serEAN + "," + "\""+$row{"EAN"}+"\""
>        ...
> end while
> 
> And later on I generate the arrays in javascript:
> 
> <script type="text/javascript" language="JavaScript">
> $(document).ready(function(){
>    var arEAN =new Array(<%= Substring($serEAN;2) %>);
>   ...
> 
> Is there a cleaner approach for this task?
> 
> Pete
> 
> 
> _______________________________________________
> Active4D-dev mailing list
> [email protected]
> http://list.aparajitaworld.com/listinfo/active4d-dev
> Archives: http://active4d-nabble.aparajitaworld.com/

_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/

Reply via email to