Getting an array back from php using $.ajax
- by Wurlitzer
A php script is giving this array (which has been passed through json_encode())
[{name:"a1",path:"b1"},{name:"a2",path:"b2"}]
I use the following function to retrieve the array to jquery:
$.ajax({
type: "POST",
url: "functions.php",
data: "action=" + something,
cache: false,
success: function(response) { alert(response); }
});
The problem is I get the array back as a string:
(new String("[{name:"a1",path:"b1"},{name:"a2",path:"b2"}}]"))
How can I get it to be a javascript array?
Help would be much appreciated.