Browse Source

test to prevent the use of eval function by parsing and splitting the ajax response into an array

master
T. Meissner 12 years ago
parent
commit
076e3444b9
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      scripts/haltestellen.js

+ 13
- 2
scripts/haltestellen.js View File

@ -35,7 +35,7 @@ function ajaxCall(dataUrl, outputElement, callback) {
if(request.readyState === 4 && request.status === 200) {
//save ajax response
var response = eval(request.responseText);
var response = request.responseText;
// check if callback is a function
if(typeof callback === "function") {
@ -55,7 +55,14 @@ function ajaxCall(dataUrl, outputElement, callback) {
console.log("anonymous function");
//var wurst = [["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"],["13","Prohlis","754"]];
/*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);
console.log(wurst);
console.log(wurst.split("#"));*/
// get the search form
var searchForm = document.getElementById("search-form");
@ -77,6 +84,10 @@ function ajaxCall(dataUrl, outputElement, callback) {
ajaxCall(hstUrl, target, function(data) {
data = data.replace(/\],\[/gi, '#');
data = data.slice(2,-2);
data = data.split("#");
var i;
var y;
var htmlOutput;


Loading…
Cancel
Save