From bfd1d38b416aca76c1ff911b21f338ea81e7216a Mon Sep 17 00:00:00 2001 From: tmeissner Date: Mon, 25 Feb 2013 17:29:02 +0100 Subject: [PATCH] next test to prevent the use of eval function by parsing and splitting the ajax response into an array --- scripts/haltestellen.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/haltestellen.js b/scripts/haltestellen.js index 469c170..10716c0 100644 --- a/scripts/haltestellen.js +++ b/scripts/haltestellen.js @@ -55,14 +55,29 @@ function ajaxCall(dataUrl, outputElement, callback) { console.log("anonymous function"); - /*var wurst = '[["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"]]'; + var hupatz; + var blub = document.getElementById("output"); + + var wurst = '[["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"]]'; console.log(wurst); - //wurst = wurst.replace(/\[\[/gi, '['); - //wurst = wurst.replace(/\]\]/gi, ']'); wurst = wurst.replace(/\],\[/gi, '#'); wurst = wurst.slice(2,-2); + wurst = wurst.split("#"); console.log(wurst); - console.log(wurst.split("#"));*/ + console.log(wurst.length); + + hupatz = ""; + for (var h = 0; h < wurst.length; h++) { + hupatz += ""; + var hallo = wurst[h].split(","); + for (var x = 0; x < hallo.length; x++) { + hupatz += ""; + } + hupatz += ""; + } + hupatz += "
" + hallo[x].slice(1,-1) + "
" + + //blub.innerHTML = hupatz; // get the search form var searchForm = document.getElementById("search-form"); @@ -102,8 +117,9 @@ function ajaxCall(dataUrl, outputElement, callback) { for (i = 0; i < dataLength; i++) { htmlOutput += ""; + var trala = data[i].split(","); for (y = 0; y < 3; y++) { - htmlOutput += "" + data[i][y] + ""; + htmlOutput += "" + data[y].slice(1,-1) + ""; } htmlOutput += ""; }