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

asked Feb 6, 2016 at 16:35
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);
 }
});
answered Feb 6, 2016 at 16:58
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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