Will Gill
Will Gill

Reputation: 587

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!

Upvotes: 0

Views: 696

Answers (1)

Anush Prem
Anush Prem

Reputation: 1481

Check PHP, JSON and JavaScript usage

Upvotes: 2

Related Questions