I am currently working on a project where data is being passed from the cilent side to the server side quite a lot. I thought that AJAX and JSON would be perfect for this. I have written a small function to generate what I thought was JSON data:
Expand|Select|Wrap|Line Numbers
- function generateJSON(pcIDList)
- {
- // set the default return
- lcReturn = "" ;
- lcJSONString = '{';
- if (pcObjectName != "" && pcIDList != "")
- {
- // take the data into a JSON structure
- laIDList = pcIDList.split(",");
- for(lnPntr in laIDList)
- {
- lcElementID = laIDList[lnPntr] ;
- lcElement = document.getElementById(lcElementID) ;
- lcJSONString += lcElement.name + ':' + lcElement.value ;
- if(lnPntr < (laIDList.length - 1))
- {
- lcJSONString += ',' ;
- }
- }
- lcJSONString += '}' ;
- lcReturn = lcJSONString ;
- }
- return lcReturn ;
- }
Expand|Select|Wrap|Line Numbers
- 'dataQuantity,sameGroup,groupNumber'
Expand|Select|Wrap|Line Numbers
- {dataQuantity:1,sameGroup:false,groupSelect:2}
Many thanks
nathj