使用PHP从数据库中提取值并将结果作为变量传递给JavaScript

I have a JS/Html file and a PHP script. The PHP file creates a database connection and returns the result of the DB query.

The html page uses an ajax request to get the data and echos it back to the html page - but it is returned as text (xmlhttp.responseText), which I can display, but can't easily manipulate.

I would like to return the data as an array that I can process in JavaScript.

Is there a way for an ajax request to include the response as a variable, instead of as raw text?

If I can provide more information to make it easier to answer, let me know!

thanks!