Getting an array back from php using $.ajax
Posted
by Wurlitzer
on Stack Overflow
See other posts from Stack Overflow
or by Wurlitzer
Published on 2010-03-30T23:04:58Z
Indexed on
2010/03/30
23:13 UTC
Read the original article
Hit count: 211
jQuery
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.
© Stack Overflow or respective owner