简体   繁体   中英

Use PHP to extract values from database and pass the results as a variable to 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM