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
user5107123
-
Why not just output something from PHP that makes sense instead, for instance JSONadeneo– adeneo2016年02月06日 16:38:51 +00:00Commented 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 problemuser5107123– user51071232016年02月06日 16:44:10 +00:00Commented Feb 6, 2016 at 16:44
-
What problem are you trying to solve by putting function calls in string data?charlietfl– charlietfl2016年02月06日 16:49:56 +00:00Commented Feb 6, 2016 at 16:49
1 Answer 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
charlietfl
172k14 gold badges125 silver badges154 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js