tags:

views:

443

answers:

2

Im getting a string (simplified) from the backend that should be :

{ "menu": "Reallocate:"}

However it comes to jsp as:

{ "menu": "Reallocate:"}

and i cannot pass this to the:

var data=eval("(" + src + ")");

as it just doesn't like it.. How can i convert this usable format?

I know that:

src = '{ "menu": "Reallocate:"}';
var data=eval("(" + src + ")");

works.

Cheers

+1  A: 

Maybe you could decode it before passing to eval. The Prototype Javascript library has built-in functions in the string class for doing it: http://prototypejs.org/api/string/unescapeHTML

Gonzalo Quero
A: 

fixed this with:

src = '{ "menu": "Reallocate:"}';
fname = fname.replace(/"/g,'"');   
document.getElementById("testout").value = fname;

you can add other bits to replace other things too. :)

joe90