I am new to javascript so please be patient with me. I have a function in php which goes like this:
public function getSubjects() {
$stmt = $this-&g
I like to use json_encode to convert the array to json so it can be used as an array of objects in JS.
PHP:
public function getSubjects() {
$stmt = $this->_db->prepare('SELECT id, subject from subjects');
$stmt->execute();
return json_encode($stmt->fetchall());
}
In javascript:
var subs = ;
console.log(subs);