我正在尝试从SQLite数据库获取响应,在PHP文件上使用XHR,但我不确定如何处理正在返回的SQLite对象目前,我只是尝试console.log响应,但我收到标题中的错误。我是否需要对响应进行字符串化?
<?php
$database = new SQLite3('cookieOrders.sqlite');
$statement = $database->prepare('SELECT creation_time FROM orders WHERE order_id = 1;');
$result = $statement->execute();
echo $result;
?>
-
function populateOrders() {
var x = new XMLHttpRequest();
x.onreadystatechange=function(){
if (x.readyState==4 && x.status==200){
var response = x.responseText;
console.log(response);
}
}
x.open("GET","./php/queryDB.php",true);
x.send();
return false;
}