If possible, how can I get (and post) data from a mysql database using javascript? I know I can use php and other languages, but I just need to know if this is possible with javascript?
如果可能,我如何使用javascript从mysql数据库中获取(和发布)数据?我知道我可以使用PHP和其他语言,但我只需要知道这是否可以使用javascript?
Thanks in advance.
提前致谢。
7 个解决方案
#1
1
That's not possible with Javascript. I could not find this with server-side javascript too.
使用Javascript是不可能的。我也找不到服务器端的javascript。
Not sure about your exact requirement, but you can use Ajax to interact with database though some server side language.
不确定您的确切要求,但您可以使用Ajax通过某种服务器端语言与数据库进行交互。
#2
1
If by Javascript you mean NodeJS on the server, this project might interest you http://github.com/sidorares/nodejs-mysql-native - however the answers above are correct if you are talking about Javascript running inside a browser or other container.
如果Javascript你的意思是NodeJS在服务器上,这个项目可能会让你感兴趣http://github.com/sidorares/nodejs-mysql-native-但是如果你在谈论在浏览器或其他容器中运行的Javascript,上面的答案是正确的。
If you want to run a vanilla javascript (for the concurrency speed) inside your own engine, I recommend looking at NodeJS and then using the NodeJS MySQL Native Driver that I linked above.
如果你想在你自己的引擎中运行一个vanilla javascript(为了并发速度),我建议你看看NodeJS,然后使用我上面链接的NodeJS MySQL Native Driver。
• http://github.com/sidorares/nodejs-mysql-native
•http://github.com/sidorares/nodejs-mysql-native
#3
1
Judging from the "iPhone" and "Android" tags, I guess, you are trying to access the local storage databases on these platforms.
从“iPhone”和“Android”标签来看,我想,您正试图访问这些平台上的本地存储数据库。
- They don't use MySQL, but SQLite.
- 他们不使用MySQL,而是使用SQLite。
- How you access them from the mobile browsers is described in the W3C draft documents for the local storage: http://dev.w3.org/html5/webstorage/ for the local storage API or http://www.whatwg.org/specs/web-apps/current-work/multipage/section-sql.html#sql for the SQL API. It should be roughly the same API on iOS and Android since both of them use the Webkit browser engine.
- 如何从移动浏览器访问它们在本地存储的W3C草案文档中有所描述:http://dev.w3.org/html5/webstorage/用于本地存储API或http://www.whatwg.org/ SQL API的specs / web-apps / current-work / multipage / section-sql.html #sql。它应该与iOS和Android上的API大致相同,因为它们都使用Webkit浏览器引擎。
#4
-1
it is not possible, javascript is executed on the client.
这是不可能的,javascript在客户端上执行。
you could make the javascript call something on the server (e.g. php script) that access the database though.
你可以让javascript调用访问数据库的服务器上的东西(例如php脚本)。
#5
-1
The Web SQL database API isn’t actually part of the HTML5 specification, but it is part of the suite of specifications that allows us developers to build fully fledged web applications, so it’s about time we dig in and check it out. Some examples are here
Web SQL数据库API实际上并不是HTML5规范的一部分,但它是规范套件的一部分,允许我们开发人员构建完全成熟的Web应用程序,因此我们需要时间深入挖掘并检查它。这里有一些例子
http://html5doctor.com/introducing-web-sql-databases/
http://html5doctor.com/introducing-web-sql-databases/
#6
-1
Do remove the tags iphone and android from this question. the tags are not relevant.
从这个问题中删除标签iphone和android。标签不相关。
And only with javascript you cant accompolish this task , GET and POST request can be handled only by server side scripting languages like php.
只有使用javascript你才能完成这项任务,GET和POST请求只能由像php这样的服务器端脚本语言来处理。
Refer : http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
请参阅:http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
#7
-1
javascript can get database from server if use AJAX , only a way is AJAX
如果使用AJAX,javascript可以从服务器获取数据库,只有一种方式是AJAX
#1
1
That's not possible with Javascript. I could not find this with server-side javascript too.
使用Javascript是不可能的。我也找不到服务器端的javascript。
Not sure about your exact requirement, but you can use Ajax to interact with database though some server side language.
不确定您的确切要求,但您可以使用Ajax通过某种服务器端语言与数据库进行交互。
#2
1
If by Javascript you mean NodeJS on the server, this project might interest you http://github.com/sidorares/nodejs-mysql-native - however the answers above are correct if you are talking about Javascript running inside a browser or other container.
如果Javascript你的意思是NodeJS在服务器上,这个项目可能会让你感兴趣http://github.com/sidorares/nodejs-mysql-native-但是如果你在谈论在浏览器或其他容器中运行的Javascript,上面的答案是正确的。
If you want to run a vanilla javascript (for the concurrency speed) inside your own engine, I recommend looking at NodeJS and then using the NodeJS MySQL Native Driver that I linked above.
如果你想在你自己的引擎中运行一个vanilla javascript(为了并发速度),我建议你看看NodeJS,然后使用我上面链接的NodeJS MySQL Native Driver。
• http://github.com/sidorares/nodejs-mysql-native
•http://github.com/sidorares/nodejs-mysql-native
#3
1
Judging from the "iPhone" and "Android" tags, I guess, you are trying to access the local storage databases on these platforms.
从“iPhone”和“Android”标签来看,我想,您正试图访问这些平台上的本地存储数据库。
- They don't use MySQL, but SQLite.
- 他们不使用MySQL,而是使用SQLite。
- How you access them from the mobile browsers is described in the W3C draft documents for the local storage: http://dev.w3.org/html5/webstorage/ for the local storage API or http://www.whatwg.org/specs/web-apps/current-work/multipage/section-sql.html#sql for the SQL API. It should be roughly the same API on iOS and Android since both of them use the Webkit browser engine.
- 如何从移动浏览器访问它们在本地存储的W3C草案文档中有所描述:http://dev.w3.org/html5/webstorage/用于本地存储API或http://www.whatwg.org/ SQL API的specs / web-apps / current-work / multipage / section-sql.html #sql。它应该与iOS和Android上的API大致相同,因为它们都使用Webkit浏览器引擎。
#4
-1
it is not possible, javascript is executed on the client.
这是不可能的,javascript在客户端上执行。
you could make the javascript call something on the server (e.g. php script) that access the database though.
你可以让javascript调用访问数据库的服务器上的东西(例如php脚本)。
#5
-1
The Web SQL database API isn’t actually part of the HTML5 specification, but it is part of the suite of specifications that allows us developers to build fully fledged web applications, so it’s about time we dig in and check it out. Some examples are here
Web SQL数据库API实际上并不是HTML5规范的一部分,但它是规范套件的一部分,允许我们开发人员构建完全成熟的Web应用程序,因此我们需要时间深入挖掘并检查它。这里有一些例子
http://html5doctor.com/introducing-web-sql-databases/
http://html5doctor.com/introducing-web-sql-databases/
#6
-1
Do remove the tags iphone and android from this question. the tags are not relevant.
从这个问题中删除标签iphone和android。标签不相关。
And only with javascript you cant accompolish this task , GET and POST request can be handled only by server side scripting languages like php.
只有使用javascript你才能完成这项任务,GET和POST请求只能由像php这样的服务器端脚本语言来处理。
Refer : http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
请参阅:http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
#7
-1
javascript can get database from server if use AJAX , only a way is AJAX
如果使用AJAX,javascript可以从服务器获取数据库,只有一种方式是AJAX