import { initializeApp } from "firebase/app";
import { getStorage } from "firebase/storage";
// TODO: Replace the following with your app's Firebase project configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
// ...
storageBucket: ''
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
// Initialize Cloud Storage and get a reference to the service
const storage = getStorage(app);
<?php
// Connect to the database
$db = new SQLite3("mydatabase.db");
// Perform a SELECT query
$result = $db->query("SELECT * FROM users");
// Print the results as a JSON array
$rows = array();
while ($row = $result->fetchArray()) {
$rows[] = $row;
}
echo json_encode($rows);
// Close the connection
$db->close();
?>
function fetchUsers() {
// Send an AJAX request to the server
const xhr = new XMLHttpRequest();
xhr.open("GET", "get_users.php");
xhr.onload = function() {
if (xhr.status === 200) {
// Update the page with the results
let users = JSON.parse(xhr.responseText);
for (let i = 0; i < users.length; i++) {
let user = users[i];
let name = user["name"];
let email = user["email"];
// ...
}
} else {
console.error(xhr.statusText);
}
};
xhr.onerror = function(error) {
console.error(error);
};
xhr.send();
}
2条答案
按热度按时间23c0lvtd1#
你可以试试这个
https://pouchdb.com/
或者,它也可以用于firebase和firebase SDK
https://firebase.google.com/docs/storage/web/start#web-version-9
1dkrff032#
要从JavaScript连接到SQLite数据库,需要使用PHP或Node.js等服务器端语言作为中介。
可以使用php sqlite连接数据库
要从Node.js连接到SQLite数据库,可使用sqlite3模块
x一个一个一个一个x一个一个二个x
用于向服务器发送AJAX请求并处理响应的JavaScript代码: