从 Chrome 扩展程序连接到数据库? [英] Connecting to DB from a Chrome Extension?

查看:50
本文介绍了从 Chrome 扩展程序连接到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 chrome 扩展程序,该扩展程序仅适用于我工作的公司内的人员.扩展需要输入 - 可以通过对共享 MySQL 数据库服务器(所有员工都可以使用只读权限访问)的简单查询生成.

I am building a chrome extension which will only be available for people within the company I work for. The extension needs input - which can be generated with a simple query to a shared MySQL DB server (to which all employees can access with read only permissions).

问题是 - 由于扩展都是客户端(主要是 Javascript) - 访问数据库和运行查询的最简单方法是什么?我是否必须为扩展创建一个 php/java(/...) 服务?

The question is - since the extension is all client side (mainly Javascript) - what's the simplest way to access the DB and run the query? Do I have to create a php/java(/...) service which does that for the extension?

推荐答案

您必须创建一个与数据库交互的中间 Web 应用程序.然后,您可以从扩展程序向您的网络应用程序的 API 发出 AJAX 调用,后者将依次查询数据库并返回结果.

You'll have to create an intermediary web app that will interface with the Database. Then you can make AJAX calls from the extension to your web app's API, which will in turn query the database and return results.

Chrome 扩展 → Web App API → MySQL

Chrome Extension → Web App API → MySQL

点击此处了解有关 Chrome AJAX API 的更多信息

这篇关于从 Chrome 扩展程序连接到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆