I know its a bit confusing question. Please let me elaborate.
I need to execute a jquery script
written in a text file that I am getting from a ajax
request.
e.g. I am getting the following code from ajax request
($($("#jstreeblock").children().children().children()[0]).children('li').attr('id'))
I need to execute and store the result of above script in a variable.
for another and simple example. I have gotten
'a'+'b'
if i execute the above script the result will be ab
but if I am running it with eval
I am getting error
script
<script>
var a = "'a'+'b'"
console.log(a); // printing 'a'+'b'
eval(a); // it should give ab but not giving any result
</script>
if I am running it as
eval(''a'+'b'')
is giving error, given below
error
VM157982:1 Uncaught SyntaxError: Unexpected string(…)(anonymous function) @ VM157981:2InjectedScript._evaluateOn @ VM156978:878InjectedScript._evaluateAndWrap @ VM156978:811InjectedScript.evaluate @ VM156978:667
Please help and many thanks