0

I have response from Php Like this

"['console.log(\"ok ok \")','console.log(\"pagelet.js loaded\")','','']"

its an Array but its string how can i convert it to Array

i thinking about

split by ,

but i must remove the []
so if any body have another idea please Write it :)

also another idea its

new function

and

parse

but i dont want to use them now if there are none idea i will use them

3
  • Why not just output something from PHP that makes sense instead, for instance JSON Commented Feb 6, 2016 at 16:38
  • i output Json :D but i have some function inside Json i must run them so i loaded them scripts as array also and run them functions as array but its and string this is the problem Commented Feb 6, 2016 at 16:44
  • What problem are you trying to solve by putting function calls in string data? Commented Feb 6, 2016 at 16:49

1 Answer 1

1

This would be much simpler not putting function calls in string data and using object properties to accomplish the same thing using client side logic

JSON

[{"log": "ok ok"},{"log": "pagelet.js loaded"},{"log":false},{"log":false}]

JS (after parsing json)

$.each(serverArray, function(_, item){
   if(item.log){
       console.log(item.log);
   }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.