Is there any way to filter the dataURL result in smatClient because i need to do it on the client side
typo3 response - JSON wrapped in the <div> tags (cant remove the tags and divs in typo3 so i need to filter it on the client side)
so i need to remove the comments and get the JSON ([ { ...JSON... } ])
I wrote this code:
ok i filter out the string at the beginning of the Response but can't transform it back to json :|
it returns something but it's not correcly formated - the Loading data... disapears but the grid is empty (how to debug it ???)
(when i call the json source file without the comments and divs(remove it manually) with dataFormat: "json" - it works )
source json:
typo3 response - JSON wrapped in the <div> tags (cant remove the tags and divs in typo3 so i need to filter it on the client side)
Code:
<?xml version="1.0" encoding="UTF-8"?> <!-- BEGIN: Content of extension "api_typo3plugin", plugin "tx_typo3plugin_pi4" --> <div class="tx-apidashboard-pi4"> [ { ...JSON... } ] </div> <!-- END: Content of extension "api_typo3plugin", plugin "tx_typo3plugin_pi4" -->
I wrote this code:
Code:
isc.DataSource.create({ ID:"xx", dataFormat:"custom", // not json /xml -must be custom !! dataURL:"http://mysite.com/source.json", transformResponse: function(dsResponse, dsRequest, data){ var test = dsResponse.data; // get only JSON from, the response var atpos = test.indexOf("["); var atpos2 = test.indexOf("]"); if (atpos > -1) { test = test.substring(atpos,atpos2+1); } dsResponse.data =test; data =test; this.dataFormat="json"; //set dataformat back to json dsResponse.data = JSON.parse(dsResponse.data); return dsResponse; }
it returns something but it's not correcly formated - the Loading data... disapears but the grid is empty (how to debug it ???)
(when i call the json source file without the comments and divs(remove it manually) with dataFormat: "json" - it works )
source json:
Code:
[ {"nmr":"022242069","nmr2":"122638958","price":"0.06","code":null,"time":"01.01.2011 14:08:17","duration":"18"},{"nmr":"062244233","nmr2":"112638958","price":"0.04","code":null,"time":"01.01.2011 21:01:53","duration":"14"} ]
Comment